Delphi Tips&Tricks News   Tips   .NET Software   VCL Software   Search   Contacts
Ultimate Pack - special offer!

Ultimate Pack  hot!
Image Editor  new!
Runtime Fusion
Form Designer
Object Inspector
Print Suite Pro
Commented Image
Delphi Toys
WinDowse
Delphi Bonus
TMS Scripter Studio
Form Designer VB
Form Designer .NET

...get more...
for Delphi.NET, C#, VB.NET
for Delphi VCL, BCB 3-6

WinAPI Online
Unix Manual Pages
MegaDetailed.NET
in3steps.com
cdtrrracks.com new!

Blogspot  greatis.blogspot.com

Set a color lines in ListBox - Components - Tips & Tricks - Greatis Delphi Pages

First of all, you should set Style method to lbOwnerDrawFixed.
And then use OnDrawItem event with lines:


procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
var
  Mas: array[1..5] of Integer;
begin
  Mas[1]:=clRed;
  Mas[2]:=clBlue;
  Mas[3]:=clYellow;
  Mas[4]:=clAqua;
  Mas[5]:=clGreen;
  with (Control as TListBox).Canvas do
  begin
    Brush.Color:=Mas[Index+1];
    FillRect(Rect);
    TextOut(Rect.Left,Rect.Top,IntToStr(Index+1));
  end;
end;
Related topics
Stick graphics in ListBox

For more
Delphi Help

Download source