Skip to main content
A newer version of this page is available. .

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:

ComboBoxEdit_CustomDraw

using DevExpress.XtraEditors;

private void comboBoxEdit1_DrawItem(object sender, ListBoxDrawItemEventArgs e){
    if ((e.State & DrawItemState.Selected) > 0) {
      Font boldFont = new Font(e.Appearance.Font.FontFamily, e.Appearance.Font.Size, FontStyle.Bold);
      e.Graphics.DrawString(e.Item.ToString(), boldFont, new SolidBrush(e.Appearance.ForeColor),
        e.Bounds);
      e.Handled = true;
    }
}