Как в ListBox нарисовать Item своим цветом?
Falk0ner, вс, 06/07/2008 - 15:34.
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin
With ListBox1 do
begin
If odSelected in State then
Canvas.Brush.Color:=clTeal { твой цвет }
else
Canvas.Brush.Color:=clWindow;
Canvas.FillRect(Rect);
Canvas.TextOut(Rect.Left+2,Rect.,Items[Index]);
end;
end;
Rect: TRect; State: TOwnerDrawState);
begin
With ListBox1 do
begin
If odSelected in State then
Canvas.Brush.Color:=clTeal { твой цвет }
else
Canvas.Brush.Color:=clWindow;
Canvas.FillRect(Rect);
Canvas.TextOut(Rect.Left+2,Rect.,Items[Index]);
end;
end;
Hе забудьте установить свойство Style у своего ListBox в lbOwnerDrawFixed или в
lbOwnerDrawVariable.
Взято из http://forum.sources.ru
Отправить комментарий