[Overview][Constants][Types][Classes][Procedures and functions][Index] | Reference for unit 'ColorBox' (#lcl)

# TCustomColorBox.OnGetColors

OnGetColors - event handler for the instruction to get colors.

## Declaration

Source position: colorbox.pas line 91

`public property TCustomColorBox.OnGetColors : TGetColorsEvent read FOnGetColors write FOnGetColors;`

## Description

OnGetColors is a TGetColorsEvent property with the event handler signalled to get custom colors used in the combo-box control.

An application must implement and assign an object procedure using the signature in TGetColorsEvent to respond to the notification. Sender is the TCustomColorBox control for the event notification. Items is the TStrings instance with the existing color names and values stored in the control.

The event handler can perform any actions needed to populate the list of Items. This can include clearing the Items, adding or removing selected names and color values, or using color names and/or values not defined as color constants in the graphics.pp unit. It could also be used to implement a custom color palette with specific pre-defined color combinations.

Some common operations:

Clear the list of ltems:

    Items.Clear;

Add a specific color:

    Items.AddObject(rsSkyBlueColorCaption,
    TObject(PtrInt(clSkyBlue)));

Delete a specific color:

    iPos := Items.IndexOf(rsSkyBlueColorCaption);
    if iPos <> -1 then
    Items.Delete(iPos);

OnGetColors is signalled (when assigned) when the color list is loaded for the control, and cbCustomColors has been included in the Style for the control. This occurs when a new value is assigned to the Style property.

## See also

TCustomColorBox.Style |  | Settings which determine the colors available in the control and their display style.
TCustomColorBox.Colors |  | Provides indexed access to the TColor value for items in the control.
TCustomColorBox.ColorNames |  | Provides indexed access to the names for the Colors used in the control
TGetColorsEvent |  | Specifies an event handler used to get the colors in a color control.
TColorBoxStyles |  | Represents the available colors and the name display style used in color controls.
TCustomComboBox.Items |  | The list of items displayed in the combo-box control.