Skip to main content
All docs
V24.2

RepositoryItemComboBox.CustomizeItem Event

Allows you to customize templated items dynamically.

Namespace: DevExpress.XtraEditors.Repository

Assembly: DevExpress.XtraEditors.v24.2.dll

Declaration

[DXCategory("Behavior")]
public event CustomizeComboBoxItemEventHandler CustomizeItem

Event Data

The CustomizeItem event's data class is DevExpress.XtraEditors.Repository.CustomizeComboBoxItemEventArgs.

Remarks

A ComboBoxEdit control can render its items based on HTML-CSS templates that you can create with the RepositoryItemComboBox.HtmlTemplates property at design time or in code.

The CustomizeItem event fires for each templated item that is about to be displayed. A template typically consists of one or more elements. You can access and customize these template elements while handling the CustomizeItem event.

Use the event’s e.HtmlElement parameter to access individual HTML template elements. The following methods allow you to retrieve HTML elements by tag, class, and ID:

  • HtmlElement.FindElementsByTag — Returns a list of HTML elements that have the specified tag.
  • HtmlElement.FindElementsByClass — Returns a list of HTML elements that are of the specified class.
  • HtmlElement.FindElementById — Returns an HTML element with the specified ID.

The elements returned by these methods expose properties to change element display settings. The main properties include:

  • element.Hidden — Allows you to hide the element.
  • element.Style — Allows you to modify CSS style properties applied to the element. This object exposes the SetBackgroundColor, SetForeColor, and SetProperty methods for this purpose.

Example

The following example changes the background color of a ‘status’ HTML element:

void comboBoxEdit1_Properties_CustomizeItem(object sender, CustomizeComboBoxItemEventArgs e) {
    var statusBadge = e.HtmlElement?.FindElementById("status");
    bool online = employeesOnline[e.Index];
    if(statusBadge != null && online)
        statusBadge.Style.SetBackgroundColor("@Green");
}
See Also