Title: Colourful lines in ListBox
Question: How to make the colourful lines in ListBoxes?
Answer:
Place in the OnDrawItem event of the ListBox the following code:
With ( Control As TListBox ).Canvas Do
begin
Case Index Of
0:
begin
Font.Color := clWhite;
Brush.Color := clRed;
end;
1:
begin
Font.Color := clSilver;
Brush.Color := clNavy;
end;
2:
begin
Font.Color := clWhite;
Brush.Color := clFuchsia;
end;
end;
FillRect(Rect);
TextOut(Rect.Left, Rect.Top, ( Control As TListBox ).Item[Index]);
end;