TcxCustomColorComboBoxProperties.PrepareDelphiColorList(Boolean,Boolean) Method
Populates the color combo box with the default Delphi color list.
Declaration
procedure PrepareDelphiColorList(const ASaveCustom: Boolean; const ASaveMRU: Boolean);
Parameters
Name | Type |
---|---|
ASaveCustom | Boolean |
ASaveMRU | Boolean |
Remarks
Use the PrepareDelphiColorList method to populate the color combo box editor with standard Delphi colors. The method first clears the list of displayed items and then adds all the colors from the Delphi set (descriptions are also assigned to items using the corresponding naming convention).
To populate the color combo box control with colors from another predefined set, use the PrepareHTML4ColorList, PrepareX11ColorList or PrepareX11OrderedColorList method.
The ASaveCustom parameter identifies whether user-defined colors are saved when the new color set is loaded into the color combo box. The ASaveMRU parameter identifies whether the MRU colors list is saved when the new color set is loaded.
Note that you can specify the color list used in the color combo box at design-time using the Properties.NamingConvention property. However, this property only has an effect when the Properties.Items collection is empty. Otherwise, it simply changes the color naming convention. Also, changing the Properties.NamingConvention property at runtime has no effect on the set of colors displayed by the control. Thus, if you need to load a predefined color set, use one of the methods listed above. Another use of these methods is to reset the list of colors. This is useful, for instance, if you allow end-users to add their own colors to the list, but want to have the ability to discard changes made by them.
The following is a sample color combo box populated with default Delphi colors:
Note that when Delphi color list is loaded into the control, all color descriptions start with a ‘cl‘ string (as in the Delphi IDE). Sometimes, you may want to avoid such behavior by handling the Properties.OnNamingConvention event as shown below. (The event lets you correct the description of each color).
procedure TForm1.cxColorComboBox1PropertiesNamingConvention(
Sender: TObject; const AColor: TColor; var AColorDescription: string);
begin
if LeftStr(AColorDescription, 2) = 'cl' then
AColorDescription := MidStr(AColorDescription, 3, Length(AColorDescription) - 2);
end;
If the event is handled as above, the combo box will look as displayed below.
Note
when loading a predefined color set into the color combo box, be sure that the Properties.NamingConvention property is set to the corresponding value or cxncNone. For instance, if calling the PrepareDelphiColorList method, ensure that the Properties.NamingConvention property value is cxncDelphi or cxncNone. Otherwise, colors that are not recognized by the specified naming convention will be displayed using RGB codes. Note that this only matters if color descriptions are displayed (the Properties.ShowDescription property value is True).