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

# TCustomColorListBox

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Implements the base class for TColorListBox.

## Declaration

Source position: colorbox.pas line 170

`type TCustomColorListBox = class(TCustomListBox)`
`protected`
`function ColorRectWidthStored;` |  | Implements the storage specifier for the ColorRectWidth property.
`procedure DrawItem(); override;` |  | Draws the color preview and name for an item in list box control.
`procedure SetColorList;` |  | Loads the list of colors used in the control.
`procedure Loaded; override;` |  | Performs actions needed when LCL component streaming has been completed.
`procedure InitializeWnd; override;` |  | Performs actions needed when the window handle for the control is created.
`procedure DoAutoAdjustLayout(); override;` |  | Performs actions needed to auto-adjust the control using the specified layout policy.
`procedure DoGetColors; virtual;` |  | Signals the OnGetColors event handler (when assigned).
`procedure DoSelectionChange(); override;` |  | Performs actions needed when the selection in the control is changed.
`function PickCustomColor; virtual;` |  | Selects a custom color using a color dialog.
`procedure Notification(); override;` |  | Performs actions needed when the specified component is added to or removed from the control.
`public`
`constructor Create(); override;` |  | Constructor for the class instance.
`property ColorRectWidth: Integer; [rws]` |  | Width for the color sample (swatch) displayed for colors in the item list.
`property ColorRectOffset: Integer; [rw]` |  | Number of pixels between the color sample and the color name.
`property Style: TColorBoxStyle; [rw]` |  | Settings which determine the colors available in the control and their display style.
`property Colors []: TColor; [rw]` |  | Provides indexed access to the TColor value for items in the control.
`property ColorNames []: string; [r]` |  | Provides indexed access to the names for the Colors used in the control.
`property Selected: TColor; [rw]` |  | The TColor value for the selected item in the list box control.
`property DefaultColorColor: TColor; [rw]` |  | TColor used for the clDefault color constant.
`property NoneColorColor: TColor; [rw]` |  | TColor used for the clNone color constant.
`property OnGetColors: TLBGetColorsEvent; [rw]` |  | OnGetColors - event handler for the instruction to get colors.
`property ColorDialog: TColorDialog; [rw]` |  | Dialog displayed to select a custom color for the control.
`end;`

## Inheritance

`TCustomColorListBox` |  | Implements the base class for TColorListBox.
`TCustomListBox` |  | The base class for TListBox.
`TWinControl` |  | Implements a windowed control which can contain other child controls.
`TControl` |  | The base class for visible controls.
`TLCLComponent` |  | The base class for LCL components which have an associated widget.
`TComponent`
?
`TObject`

## Description

TCustomColorListBox is a TCustomListBox descendant which implements a list box control used to display and select color names and values. TCustomColorListBox is the base class for the TColorListBox control. Each item in the control has a small rectangle where the color is displayed (swatch) and the color name.

The Style property is used to configure the list of available colors and their display names. Style may also trigger use of the OnGetColors event handler to get the items displayed in the combo-box control.

The ColorRectWidth and ColorRectOffset properties can be used to control the size and spacing for the color swatch displayed for the list items.

Colors allows indexed access to the TColor values in the list of items. When included in the Style property, colors like clDefault and/or clNone may be included in the list of Colors. The DefaultColorColor and NoneColorColor properties can be used to specify the TColor values used for those color constants.

ColorNames allows indexed access to the names for the values in Colors.

Do not create instances of TCustomColorListBox; use the TColorL:istBox descendant instead.

Use TCustomColorBox / TColorBox to display color names and values in a combo-box control.

## See also

TColorListBox |  | Implements a list box control used to display and select color names and values.
TCustomColorBox |  | The base class for TColorBox.
TColorBox |  | Implements combo-box control used to select a color name or value.
TCustomListBox |  | The base class for TListBox.