111,130
社区成员
发帖
与我相关
我的任务
分享
private void moveComboBox1_DrawItem(object sender, DrawItemEventArgs e)
{
//Console.WriteLine(e.State.ToString());
if (e.State == DrawItemState.Selected)
{
e.Graphics.FillRectangle(new SolidBrush(Color.Beige), new RectangleF(e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1));
label1.Text = moveComboBox1.Items[e.Index].ToString();
}
else if (e.State == DrawItemState.None)
{
e.Graphics.FillRectangle(new SolidBrush(Color.White), new RectangleF(e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1));
}
e.Graphics.DrawString(moveComboBox1.Items[e.Index].ToString(), moveComboBox1.Font, new SolidBrush(Color.Black), 2, e.Bounds.Y + 2);
}
private void moveComboBox1_DrawItem(object sender, DrawItemEventArgs e)
{
//Console.WriteLine(e.State.ToString());
if (e.State == DrawItemState.Selected)
{
e.Graphics.FillRectangle(SystemBrushes.MenuHighlight, new RectangleF(1, 1, e.Bounds.Width - 1, e.Bounds.Height - 1));
label1.Text = moveComboBox1.Items[e.Index].ToString();
}
if (e.State == DrawItemState.None)
{
e.Graphics.FillRectangle(new SolidBrush(Color.White), new RectangleF(1, 1, e.Bounds.Width - 1, e.Bounds.Height - 1));
}
e.Graphics.DrawString(moveComboBox1.Items[e.Index].ToString(), moveComboBox1.Font, SystemBrushes.ControlText, 2, e.Bounds.Y + 2);
}