对C# 中Combox控件的一些简单的操作,改变其显示特性,主要是改变其中的项的属性 我们需要注意的是:每次为Combox添加项的时候,就会触发DrawItem事件,而我们正是通过DrawItem来改变Combox的显示特性的 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Collections; namespace Combox_Image { public partial class Form1 : Form { ArrayList brushArray = new ArrayList() ; ArrayList fontArray = new ArrayList() ; public Form1() { InitializeComponent(); } private void comboBox1_DrawItem(object sender, DrawItemEventArgs e) { //确定画布 Graphics g = e.Graphics; //绘制区域 Rectangle r = e.Bounds; Font fn = null; if (e.Index >= 0) { //设置字体、字符串格式、对齐方式 fn = (Font)fontArray[e.Index]; string s = (string)comboBox1.Items[e.Index]; StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Near; //根据不同的状态用不同的颜色表示 if (e.State == (DrawItemState.NoAccelerator | DrawItemState.NoFocusRect)) { e.Graphics.FillRectangle(new SolidBrush(Color.Red), r);