Çeviri: Ramazan Gülbahar.
TListboxın MultiSelect özelliğini False yapın.
Not: Forma bir TListBox ekleyin ve items özelliğine metinler girin:
Kod: Tümünü seç
procedure TForm1.FormCreate(Sender: TObject);
begin
ListBox1.Style := lbOwnerDrawFixed;
ListBox1.ItemHeight := 20;
ListBox1.OnDrawItem := ListBox1DrawItem;
end;
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
const
IsSelected : array[Boolean] of Integer = (DFCS_BUTTONRADIO, DFCS_BUTTONRADIO or DFCS_CHECKED) ;
var
optionButtonRect: TRect;
listBox : TListBox;
begin
listBox := Control as TListBox;
with listBox.Canvas do
begin
FillRect(rect) ;
optionButtonRect.Left := rect.Left + 1;
optionButtonRect.Right := Rect.Left + 13;
optionButtonRect.Bottom := Rect.Bottom;
optionButtonRect.Top := Rect.Top;
DrawFrameControl(Handle, optionButtonRect, DFC_BUTTON, IsSelected[odSelected in State]) ;
TextOut(15, rect.Top + 3, listBox.Items[Index]) ;
end;
end;
end.