Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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) {
        e.Appearance.FontStyleDelta = FontStyle.Bold;
        e.Cache.DrawString(e.Item.ToString(), e.Appearance.Font, e.Appearance.GetForeBrush(e.Cache),
            e.Bounds);
        e.Handled = true;
    }
}