Это пример изменения цветов строк
Код:
procedure TTest.ListBox1DrawItem(Control: TWinControl;
Index: Integer; Rect: TRect; State: TOwnerDrawState);
begin
with (Control as TListBox).Canvas do
begin
case Index of
0:
begin
Font.Color := clBlue;
Brush.Color := clYellow;
end;
1:
begin
Font.Color := clRed;
Brush.Color := clLime;
end;
2:
begin
Font.Color := clGreen;
Brush.Color := clFuchsia;
end;
end;
FillRect(Rect);
TextOut(Rect.Left, Rect.Top, (Control as TListBox).Items[Index]);
end;
end;
Можно менять и стиль шрифта, используя Font.Style:
Код:
procedure TTest.ListBox1DrawItem(Control: TWinControl;
Index: Integer; Rect: TRect; State: TOwnerDrawState);
begin
with (Control as TListBox).Canvas do
begin
case Index of
0:
begin
Font.Style := fsBold;
Brush.Color := clYellow;
end;
1:
begin
Font.Style := fsItalic;
Brush.Color := clLime;
end;
2:
begin
Font.Style := fsUnderline;
Brush.Color := clFuchsia;
end;
end;
FillRect(Rect);
TextOut(Rect.Left, Rect.Top, (Control as TListBox).Items[Index]);
end;
end;