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

# TCustomColorBox

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

The base class for TColorBox.

## Declaration

Source position: colorbox.pas line 46

`type TCustomColorBox = class(TCustomComboBox)`
`protected`
`function ColorRectWidthStored;` |  | Implements the storage specifier for the ColorRectWidth property.
`procedure DrawItem(); override;` |  | Draws an item in the combo-box control.
`procedure SetColorList;` |  | Loads the list of colors used in the control.
`procedure Loaded; override;` |  | Performs actions when a component has been loaded during LCL streaming.
`procedure InitializeWnd; override;` |  | Performs actions need to initial the window Handle for the control.
`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 CloseUp; override;` |  | Performs actions needed when the drop-down list for the control is closed.
`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; [r]` |  | 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 combo-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: TGetColorsEvent; [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

`TCustomColorBox` |  | The base class for TColorBox.
`TCustomComboBox` |  | The base class for combo-box components.
`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

TCustomColorBox is a TCustomComboBox descendant which implements the base class for TColorBox. TCustomColorBox displays available colors in a combo-box 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 TCustomColorBox; use the TColorBox descendant instead.

Use TCustomColorListBox / TColorListBox to display color names and values in a list box control.

## See also

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