TcxColorComboBoxItems.GetIndexByColor(TColor) Method
Gets the index of the item representing a specified color.
Declaration
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:
var BlackColorIndex: Integer;
// ...
BlackColorIndex := cxColorComboBox1.Properties.Items.GetIndexByColor(clBlack);
cxColorComboBox1.Properties.Items.Delete(BlackColorIndex);