10

I'm using the OnGetColors event of the TColorBox component, but I can't figure out how add new colors using the Items property of the item parameter of the Event.

procedure (Sender: TCustomColorBox; Items: TStrings) of object;

How I must add new colors to the TColorBox using the Items property?

Salvador
  • 16,132
  • 33
  • 143
  • 245

1 Answers1

11

you must use the AddObject method of the Items object, like so :

procedure TForm1.ColorBox1GetColors(Sender: TCustomColorBox; Items: TStrings);
begin
   Items.AddObject('clWebSnow',TObject(clWebSnow));
end;
RRUZ
  • 134,889
  • 20
  • 356
  • 483
  • 4
    What an ugly choice by the designer of that control. I wish they had made a TColorItems list type so you could call `items.AddColor( 'color name', value:TColor )` – Warren P Jan 17 '12 at 20:33