Skip to main content

How to: Custom Paint ComboBoxEdit's Items

The following ComboBoxEdit.DrawItem event handler shows how you can perform custom painting of items in the dropdown list.

Selected items are drawn with the bold font. For other items, the default control’s painting is performed.

The following image shows a combo box editor whose items are drawn in this manner:


using DevExpress.XtraEditors;

private void comboBoxEdit1_DrawItem(object sender, ListBoxDrawItemEventArgs e){
    if((e.State & DrawItemState.Selected) > 0) {
        e.Appearance.FontStyleDelta = FontStyle.Bold;
        e.Cache.DrawString(e.Item.ToString(), e.Appearance.Font, e.Appearance.GetForeBrush(e.Cache),
        e.Handled = true;