Recent

Author Topic: TColorListBox problems setting colors in Lazarus 9.26.2, GTK 2, Ubuntu 9.10  (Read 5950 times)

grunell

  • Newbie
  • Posts: 3
Lazarus 9.26.2 changed how colors are set.  Previously used TColorListBox.Items.Add('clRed'), or  TColorListBox.Items.Strings[index] :='clRed', for example.  Neither of these work in the new Laz version.  Does anyone know how to set the colors at run time?

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1927
Set in Style cbCustomColors to true

And use the event OnGetColors:

Code: [Select]
procedure TForm1.ColorListBox1GetColors(Sender: TCustomColorListBox;
  Items: TStrings);
begin
  Items.Clear;
  Items.AddObject('red', TObject(PtrInt(clRed)));
  Items.AddObject('yellow', TObject(PtrInt(clYellow)));
end;

grunell

  • Newbie
  • Posts: 3
Thanks Theo.  Worked perfectly.

 

TinyPortal © 2005-2018