Einzelnen Beitrag anzeigen

obscureSg

Registriert seit: 14. Jun 2007
7 Beiträge
 
#12

Re: Bestimmte Zeilen einer TListbox färben

  Alt 14. Jun 2007, 20:25
geht nicht!!! hier nochma ein code :



Delphi-Quellcode:
implementation

{$R *.DFM}


procedure ZeileFaerben(Zeile:integer;Farbe:integer;Listbox1:TListbox;
  Index:Integer;Rect:TRect);
begin
  if Index<>Zeile then
    Farbe:=clBlack;

  Listbox1.Canvas.Brush.Color:=clWhite;
  Listbox1.Canvas.Pen.Color:=Farbe;
  Listbox1.Canvas.FillRect(Rect);
  Listbox1.Canvas.Font.Color:=Farbe;
  Listbox1.Canvas.TextOut(Rect.Left,Rect.Top,Listbox1.Items[Index]);
end;

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;

end.
  Mit Zitat antworten Zitat