日期:2014-05-17 浏览次数:20855 次
this.comboBox1.DrawMode = DrawMode.OwnerDrawFixed; this.comboBox1.DrawItem += new DrawItemEventHandler(comboBox1_DrawItem); } void comboBox1_DrawItem(object sender, DrawItemEventArgs e) { string txt = this.comboBox1.Items[e.Index].ToString(); Graphics g = e.Graphics; Font f = new Font("宋体", 9); if (e.State == DrawItemState.Selected) { this.label2.Text = txt; g.FillRectangle(Brushes.Blue, 0, e.Index * 15, this.comboBox1.Width, 12); g.DrawString(txt, f, Brushes.White, 0, e.Index * 15); } else { g.FillRectangle(Brushes.White, 0, e.Index * 15, this.comboBox1.Width, 12); g.DrawString(txt, f, Brushes.Black, 0, e.Index * 15); } }