1. 將ComboBox的DrawMode屬性改成OwnerDrawFixed
2. 建立DrawItem的Event
private void DrawItem(object sender, DrawItemEventArgs e) { ComboBox cBox = (ComboBox)sender; e.DrawBackground(); if (e.Index == 0) e.Graphics.DrawString(cBox.Items[e.Index].ToString(), cBox.Font, new SolidBrush(Color.Red), (Rectangle)e.Bounds); else e.Graphics.DrawString(cBox.Items[e.Index].ToString(), cBox.Font, new SolidBrush(Color.Black), (Rectangle)e.Bounds); e.DrawFocusRectangle(); }
沒有留言:
張貼留言