Mega Code Archive

 
Categories / Delphi / Graphic
 

Set a color lines in ListBox

Title: Set a color lines in ListBox 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;