Reputation: 2321
I am trying to add a custom color to a TColorBox
control. I've added the control to my form and for the Style
property, set cbCustomColor
to True. For the OnGetColors
event, I have the following code:
procedure TfrmAbout.GetColors(Sender: TCustomColorBox; Items: TStrings);
begin
ShowMessage('GetColors has been triggered');
Items.AddObject('clWebSnow',TObject(clWebSnow));
Items.AddObject('MyOrange',TObject(Rgb(255,128,0)));
end;
I don't see the messagebox or the colors appearing in the dropdown. Is there anything else I need to do in order to get this to work?
Upvotes: 3
Views: 838
Reputation: 2321
In order to get this to work I did have to follow @Sertac's suggestion. On FormCreate, I fired a procedure that removed the [cbCustomColors]
then added them back in, for each TColorBox.
I could not find another suitable work around or figure out why GetColors was not firing when it should.
Upvotes: 0
Reputation: 76693
You need to include the cbCustomColors
option to the Style
property to enable adding of your own custom colors instead. The cbCustomColor
option only includes the item, which allows you to select a custom color.
Upvotes: 5