Einzelnen Beitrag anzeigen

Benutzerbild von toms
toms
(CodeLib-Manager)

Registriert seit: 10. Jun 2002
4.648 Beiträge
 
Delphi XE Professional
 
#10

Re: Listbox färbt komisch ein

  Alt 25. Sep 2008, 22:05
Delphi-Quellcode:
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  with (Control as TListBox) do
  begin
    if Index = 2 then //bei best. Zeile soll folgendes gelten
    begin
      Canvas.Brush.Color := clRed;
      Canvas.Pen.Color := clWhite;
    end
    else
    begin
      //falls gewünscht
      Canvas.Brush.Color := clWhite;
      Canvas.Pen.Color := clBlack;
    end;

     if (odSelected in State) then
     begin
       Canvas.Font.Color := clHighlightText;
       Canvas.Brush.Color := clHighlight;
     end else
       Canvas.Font.Color := clWindowText;

    Canvas.FillRect(Rect);
    Canvas.TextRect(Rect, Rect.Left + 1, Rect.Top + 1, Items[Index]);
  end;
end;
Thomas
  Mit Zitat antworten Zitat