public partial class Form1 : Form
{
List<string> its = new List<string>();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
comboBox1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;
}
private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)
{
string s = comboBox1.Items[e.Index].ToString();
Color c = its.Contains(s) ? Color.LightBlue : Color.White;
Font font = new Font("
宋体", 8);
Rectangle r = new Rectangle(2, e.Bounds.Top + 2,
e.Bounds.Height, e.Bounds.Height - 4);
e.DrawBackground();
e.Graphics.FillRectangle(new SolidBrush(c), r);
e.Graphics.DrawString(s, font, Brushes.Black, new RectangleF(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height));
e.DrawFocusRectangle();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
its.Add(comboBox1.Text);
}
}