Отключение выбранного элемента.
public Form1()
{
_dataItems = new List<DataItem>
{
new DataItem {Name = "Alpha", IsBold = true, OtherData = new object()},
new DataItem {Name = "Beta", IsBold = false, OtherData = new object()},
new DataItem {Name = "Gamma", IsBold = true, OtherData = new object()},
};
this.InitializeComponent();
comboBox1.DrawItem += comboBox1_DrawItem;
comboBox1.DataSource = _dataItems;
comboBox1.DisplayMember = "Name";
comboBox1.ValueMember = "OtherData";
}
void comboBox1_DrawItem(object sender, DrawItemEventArgs e)
{
var dataItem = (DataItem)comboBox1.Items[e.Index];
if (dataItem.IsBold)
e.Graphics.DrawString(dataItem.Name, BoldFont, SystemBrushes.ControlText,
e.Bounds);
else
e.Graphics.DrawString(dataItem.Name, NormalFont, SystemBrushes.ControlText,
e.Bounds);
}
Класс DataItem:
public class DataItem
{
public String Name { get; set; }
public bool IsBold { get; set; }
public Object OtherData { get; set; }
public override string ToString()
{
return Name;
}
}