Einzelnen Beitrag anzeigen

Niko

Registriert seit: 23. Jun 2003
416 Beiträge
 
Delphi 2006 Professional
 
#2

Re: "Rahmen" innerhalb einer Combobox

  Alt 18. Okt 2005, 20:50
Hi,

das geht, indem du die Eigenschaft Style deiner ComboBox auf csOwnerDrawFixed setzt und den Inhalt selber zeichnest.

Etwa so:
Delphi-Quellcode:
procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  ComboBox1.Canvas.Pen.Color := clRed;
  ComboBox1.Canvas.Rectangle(Rect);
  Rect.Left := Rect.Left + 1;
  Rect.Top := Rect.Top + 1;
  Rect.Right := Rect.Right - 1;
  Rect.Bottom := Rect.Bottom - 1;
  ComboBox1.Canvas.Brush.Style := bsClear;
  ComboBox1.Canvas.TextRect(Rect, Rect.Left, Rect.Top, ComboBox1.Items[Index]);
end;
"Electricity is actually made up of extremely tiny particles called electrons, that you cannot see with the naked eye unless you have been drinking." (Dave Barry)
  Mit Zitat antworten Zitat