It depends a little on how you want to pin the element. If you want the text of the selected element to be in bold, you can achieve this like this (for this you need to set DrawMode from ComboBox to OwnerDrawFixed and, of course, hook the DrawItem event to the event handler):
I populated the combo box with Template objects, defined as follows:
private class Template { public string Name { get; set; } public bool IsDefault { get; set; } public override string ToString() { return this.Name; } }
... and the DrawItem event is executed as follows:
private void ComboBox_DrawItem(object sender, DrawItemEventArgs e) { if (e.Index < 0) { return; } Template template = comboBox1.Items[e.Index] as Template; if (template != null) { Font font = comboBox1.Font; Brush backgroundColor; Brush textColor; if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { backgroundColor = SystemBrushes.Highlight; textColor = SystemBrushes.HighlightText; } else { backgroundColor = SystemBrushes.Window; textColor = SystemBrushes.WindowText; } if (template.IsDefault) { font = new Font(font, FontStyle.Bold); } e.Graphics.FillRectangle(backgroundColor, e.Bounds); e.Graphics.DrawString(template.Name, font, textColor, e.Bounds); } }
That should make you go in the right direction, hopefully.
source share