Sign in Join
Wiki copytemporary

TColorListBox: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: TColorListBox

OldNewLine
1+![](/wiki-images/8/8f/Tcolorlistbox_screenshot.png) A **TColorListBox** ![](/wiki-images/7/72/Tcolorlistbox.png) is a component that shows a (scrollable) list of colors from which the user can select one. It is available from the [[Additional tab]] of the [[Component Palette]].
2+
3+Specific properties of `TColorListBox` are:
4+
5+- `ColorRectOffset` - margin around each color rectangle
6+- `ColorRectWidth` - width of a color rectangle
7+- `Style` - defines the items shown in the listbox, and how the colors are named
8+ - `cbStandardColors` - includes the 16 LCL standard colors in the list, e.g. `clRed` or `clBlue`
9+ - `cbExtendedColors` - includes the 4 LCL extended colors: `clMoneyGreen`, `clSkyBlue`, `clCream`, `clMedGray`
10+ - `cbSystemColors` - includes the OS- and theme-dependent system colors
11+ - `cbIncludeNone` - includes the special color `clNone`. Use the property `NoneColorColor` to determine the replacement color. If `NoneColorColor` is set to `clNone` the color rectangle displays a crossed-out box like in many drawing programs.
12+ - `cbIncludeDefault` - include the special color `clDefault`. Property `DefaultColorColor` determines the actual color displayed.
13+ - `cbCustomColor` - the first listbox item is customizable by means of the standard color dialog.
14+ - `cbPrettyNames` - displays "pretty" color names next to the color boxes, e.g. 'Red'. Without this option the internal color names are used, e.g. 'clRed'.
15+ - `cbCustomColors` - includes user-provided colors at the end of the list. The colors must be defined by a stringlist in the `OnGetColors` event, like this:
16+
17+``` Pascal
18+ procedure TForm1.ColorListBox1GetColors(Sender: TCustomColorListBox; Items: TStrings);
19+ begin
20+ Items.AddObject('Gold', TObject(PtrInt($00D7FF)));
21+ Items.AddObject('Chocolate', TObject(PtrInt($1E69D2)));
22+ Items.AddObject('Light blue', TObject(PtrInt($E6D8AD)));
23+ end;
24+```
25+
26+\
27+==See also==
28+
29+- [[doc:lcl/colorbox/tcolorlistbox.html|TColorListBox doc]]
30+- [[TColorBox]]
31+- [[TListBox]]
32+
33+---
34+*From the Free Pascal wiki, page "TColorListBox", as it stood on 2019-08-02 after a change by Wp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history