Back to Devexpress

TcxImageComboBoxItem Class

vcl-cximagecombobox-654be59c.md

latest4.7 KB
Original Source

TcxImageComboBoxItem Class

An image combo box item.

Declaration

delphi
TcxImageComboBoxItem = class(
    TCollectionItem
)

Remarks

Like in a simple combo box, a selected image combo box item is associated with an edit value. In addition, image combo box items can display images and corresponding descriptions.

Main API Members

The list below outlines key members of the TcxImageComboBoxItem class. These members allow you to configure image combo box items.

Collection

Provides access to the parent collection.

Tip

You need to cast the property value to the TcxImageComboBoxItems class to access all public API members.

Description | ImageIndexSpecify the item’s description and image.IndexSpecifies the item’s index in the parent collection.TagAllows you to associate the image combo box item with an integer value (a pointer, for example).Value

Specifies the edit value associated with the image combo box item.

Note

Make sure that all items in the same image combo box editor have unique Value property values. If an image combo box has two or more items with identical values, the editor can display only the first item when one of them is selected.

Code Example: Create and Configure Image Combo Box Items

The following code example creates and configures four image combo box items:

delphi
var
  AItem: TcxImageComboBoxItem;
  AProperties: TcxImageComboBoxProperties;
begin
  AProperties := cxImageComboBox1.Properties;
  AProperties.BeginUpdate;
  try
    AItem := AProperties.Items.Add;
    AItem.ImageIndex := 0;
    AItem.Description := 'Dr';
    AItem.Value := 0;
    AItem := AProperties.Items.Add;
    AItem.ImageIndex := 1;
    AItem.Description := 'Mr';
    AItem.Value := 1;
    AItem := AProperties.Items.Add;
    AItem.ImageIndex := 2;
    AItem.Description := 'Ms';
    AItem.Value := 2;
    AItem := AProperties.Items.Add;
    AItem.ImageIndex := 3;
    AItem.Description := 'Mrs';
    AItem.Value := 3;
  finally
    AProperties.EndUpdate;
  end;
  cxImageComboBox1.EditValue := 0;
end;
cpp
TcxImageComboBoxItem *AItem;
  TcxImageComboBoxProperties *AProperties;
  // ...
  AProperties = cxImageComboBox1->Properties;
  AProperties->BeginUpdate();
  try
  {
    AItem = AProperties->Items->Add();
    AItem->ImageIndex = 0;
    AItem->Description = "Dr";
    AItem->Value = 0;
    AItem = AProperties->Items->Add();
    AItem->ImageIndex = 1;
    AItem->Description = "Mr";
    AItem->Value = 1;
    AItem = AProperties->Items->Add();
    AItem->ImageIndex = 2;
    AItem->Description = "Ms";
    AItem->Value = 2;
    AItem = AProperties->Items->Add();
  }
  __finally
  {
    AProperties->EndUpdate();
  }
  cxImageComboBox1->EditValue = 0;

Direct TcxImageComboBoxItem Class References

The following public API members reference a TcxImageComboBoxItem object:

TcxImageComboBoxItems.AddCreates a new image combo box item and adds it to the end of the collection.TcxImageComboBoxItems.ItemsProvides indexed access to image combo box items.

Inheritance

TObject TPersistent TCollectionItem TcxImageComboBoxItem

See Also

TcxImageComboBoxItem Members

cxImageComboBox Unit