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: Change Item's Height in ComboBoxEdit

The following example shows how to set a custom height for items in a ComboBoxEdit control by handling the RepositoryItemComboBox.MeasureItem event.

In this example, if a specific item contains a NewLine character (“\r\n” in C#), its height is doubled to fully display the item’s text.

ComboBox_MeasureItem_ex

using DevExpress.XtraEditors;
private void comboBoxEdit1_Properties_MeasureItem(object sender, MeasureItemEventArgs e) {
    ComboBoxEdit cb = sender as ComboBoxEdit;
    string itemValue = (string)cb.Properties.Items[e.Index];
    if (itemValue.Contains("\r\n"))
        e.ItemHeight = e.ItemHeight * 2;            
}