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

TcxColorComboBoxItems.GetIndexByColor(TColor) Method

Gets the index of the item representing a specified color.

#Declaration

Delphi
function GetIndexByColor(AColor: TColor): Integer;

#Parameters

Name Type
AColor TColor

#Returns

Type
Integer

#Remarks

Use the GetIndexByColor method to obtain the index of the item representing the specified color. The color to find is specified by the AColor parameter. If this color is not represented by any item within the collection, the method returns -1.

This method is useful when you want to perform actions for particular colors. For instance, you may want to display Delphi colors within your combo box, but without showing black. In this instance, set the Properties.NamingConvention property value to cxncDelphi and remove black from the list at application startup. To remove the color, first call the GetIndexByColor method to obtain the item index and then call the collection’s Delete method specifying the item index as its parameter:

Delphi
var BlackColorIndex: Integer;
// ...
BlackColorIndex := cxColorComboBox1.Properties.Items.GetIndexByColor(clBlack);
cxColorComboBox1.Properties.Items.Delete(BlackColorIndex);
See Also