Einzelnen Beitrag anzeigen

Popov
(Gast)

n/a Beiträge
 
#3

AW: Items in ComboBox rechtsbündig

  Alt 6. Mär 2013, 13:36
Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
begin
  ListBox1.Style := lbOwnerDrawFixed; //das kann man auch im ObjektInspector einstellen
end;

procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  with (Control as TListbox) do
    Canvas.TextRect(Rect, Rect.Right - Canvas.TextWidth(Items[Index]) - 2, Rect.Top, Items[Index]);
end;
Die -2 ist dafür da, damit ein kleiner Abstand zum rechten Rand besteht.
  Mit Zitat antworten Zitat