コンボボックスが空です。
public frmDlgGraphOptions()
{
InitializeComponent();
this.comboBox1 = new System.Windows.Forms.ComboBox();
arr = new String[4];
arr[0] = "Solid Line";
arr[1] = "Dashed line";
arr[2] = "Dotted Line";
arr[3] = "Dotted Line";
imageArr = new Image[4];
imageArr[0] = new Bitmap("C:\\SolidLine.png");
imageArr[1] = new Bitmap("C:\\dashedline.png");
imageArr[2] = new Bitmap("C:\\Dotted.png");
imageArr[3] = new Bitmap("C:\\Dotted.png");
comboBox1.DrawMode = DrawMode.OwnerDrawFixed;
comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
comboBox1.DrawItem += new DrawItemEventHandler(comboBox1_DrawItem);
this.comboBox1.TabIndex = 1;
this.comboBox1.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(192)), ((System.Byte)(255)));
this.comboBox1.ItemHeight = 20;
this.comboBox1.Location = new System.Drawing.Point(84, 137);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(200, 26);
groupBox1.Controls.Add(comboBox1);
OnDrawItemのコードは次のとおりです
private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)
{
// Let's highlight the currently selected item like any well
// behaved combo box should
e.Graphics.FillRectangle(Brushes.Bisque, e.Bounds);
e.Graphics.DrawImage(imageArr[e.Index], new Point(e.Bounds.X, e.Bounds.Y));
e.Graphics.FillRectangle(Brushes.Bisque, e.Bounds);
//is the mouse hovering over a combobox item??
if ((e.State & DrawItemState.Focus) == 0)
{
//this code keeps the last item drawn from having a Bisque background.
e.Graphics.FillRectangle(Brushes.White, e.Bounds);
e.Graphics.DrawImage(imageArr[e.Index], new Point(e.Bounds.X, e.Bounds.Y));
}
まず、コンボボックスにアイテムが表示されません。空のコンボボックスが表示されます。また、コンボボックスにカーソルを合わせると、e.index=-1でエラーが発生します。
ありがとうサン
}