ListBoxの項目の高さを変更します。

[C#コード]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System.Drawing;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
  public partial class Form1 : Form
  {
    public Form1()
    {
      InitializeComponent();

      listBox1.DrawMode = DrawMode.OwnerDrawFixed;
      listBox1.ItemHeight = 200;

      listBox1.Items.Add("aaa");
      listBox1.Items.Add("bbb");
      listBox1.Items.Add("ccc");
    }

    private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
    {
        if (e.Index == -1)
            return;

        e.DrawBackground();
        string itemString = (string)((ListBox)sender).Items[e.Index];
        e.Graphics.DrawString(itemString, e.Font, new SolidBrush(e.ForeColor),
             new RectangleF(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height));
        e.DrawFocusRectangle();
    }
  }
}