Einzelnen Beitrag anzeigen

toyoman

Registriert seit: 2. Jun 2003
323 Beiträge
 
Delphi 2010 Enterprise
 
#5

Re: Listbox färbt komisch ein

  Alt 25. Sep 2008, 21:06
Zitat von grenzgaenger:
dann mach doch mal einen screenshoot und häng das mal dran ...

habs mal kurz ausprobiert, mit lbOwnerDrawFixed gibt folgender code das ergebnis lt. anhang...
Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
var
 i: integer;
begin
 for i := 0 to 10 do
  ListBox1.AddItem('item: ' + inttostr(i), NIL);
end;

procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
 if control is tListbox then
 begin
  with control as tListbox do
  begin
    if Index mod 2 = 0 then //bei best. Zeile soll folgendes gelten
    begin
      Canvas.Brush.Color := clRed;
      Canvas.Pen.Color := clWhite;
      Canvas.Rectangle(Rect);
    end;
    Canvas.TextOut(Rect.Left + 1, Rect.Top + 1, Items[Index]);
  end;
 end;
und ich find das ganz in ordnung so ...
sieht bei mir nicht so aus sniff
  Mit Zitat antworten Zitat