Skip to main content
All docs
V24.2

RepositoryItemComboBox.CustomItemTemplate Event

Allows you to assign custom HTML-CSS templates to combo box items.

Namespace: DevExpress.XtraEditors.Repository

Assembly: DevExpress.XtraEditors.v24.2.dll

Declaration

[DXCategory("Behavior")]
public event CustomComboBoxItemTemplateEventHandler CustomItemTemplate

Event Data

The CustomItemTemplate event's data class is DevExpress.XtraEditors.Repository.CustomComboBoxItemTemplateEventArgs.

Remarks

When HTML-CSS templates are enabled, the control’s default behavior is to generate combo box items from the default template. The default template is the first element in the RepositoryItemComboBox.HtmlTemplates collection.

You can handle the CustomItemTemplate event to assign templates to items dynamically, and thus override an item’s default template. Use the RepositoryItemComboBox.HtmlTemplates collections to create item templates beforehand.

The currently processed item can be identified with the following properties:

  • e.Index — Specifies the item’s zero-based index in the item collection.
  • e.Item — Specifies the item’s underlying data object.

To assign an HTML-CSS template to the currently processed item, access the required template (for example, from the RepositoryItemComboBox.HtmlTemplates collection), and assign it to the e.HtmlTemplate event parameter.

void comboBoxEdit1_Properties_CustomItemTemplate(object sender, CustomComboBoxItemTemplateEventArgs e) {
    var item = e.DataItem as TodoItem;
    if (!item.HasImage)
        e.HtmlTemplate = htmlTemplate2;
}
See Also