Einzelnen Beitrag anzeigen

marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#3

Re: TCheckListBox - Elemente In unterschiedlichen Farben?

  Alt 29. Jul 2005, 13:08
Wenn du die Eigenschaft Style auf lbOwnerDrawFixed setzt, dann kannst du dir so eine Tigerente bauen:

Delphi-Quellcode:
procedure TMainForm.CheckListBoxDrawItem(Control: TWinControl;
  Index: Integer; Rect: TRect; State: TOwnerDrawState);
begin
  with (Control as TCheckListBox).Canvas do begin
    if Odd(Index)
      then Brush.Color := ColorToRGB(clGray)
      else Brush.Color := ColorToRGB(clYellow);
    FillRect(Rect);
    TextOut(Rect.Left + 2, Rect.Top, (Control as TCheckListBox).Items[Index]);
  end;
end;
Grüße vom marabu
  Mit Zitat antworten Zitat