Einzelnen Beitrag anzeigen

Benutzerbild von bitsetter
bitsetter

Registriert seit: 17. Jan 2007
1.169 Beiträge
 
Turbo Delphi für Win32
 
#9

Re: Bestimmte Zeilen einer TListbox färben

  Alt 14. Jun 2007, 11:40
Hallo,

vom Prinzip her könnte man es so machen:
Delphi-Quellcode:
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  if Control is TListbox then
  begin
    TListbox(Control).Canvas.FillRect(Rect);
    if TListbox(Control).Items.Strings[Index] = 'verliehenthen
      TListbox(Control).Canvas.Font.Color := clRed
    else
    if odSelected in State then
      TListbox(Control).Canvas.Font.Color := graphics.clHighlightText
    else
      TListbox(Control).Canvas.Font.Color := graphics.clBtnText;

    TListbox(Control).Canvas.TextOut(Rect.Left, Rect.Top, TListbox(Control).Items[Index]);
  end;
end;
Der Code müsste allerdings noch erweitert werden, wenn es noch besser aussehen soll.
Gruß bitsetter
"Viele Wege führen nach Rom"
Wolfgang Mocker (geb. 1954), dt. Satiriker und Aphoristiker
  Mit Zitat antworten Zitat