var
Form1: TForm1;
RB:TRadioButton ;
implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
var
i:Integer ;
col:Integer ;
Row:Integer ;
Mlist:array[0..9]of string ;
begin
combobox1.Clear ;
col:=0;
Row:=0 ;
for i:=0 to 9 do
begin Mlist[i] :=IntToStr(i); RB:=TRadioButton.Create(self);
RB.Caption :=Mlist[i]; GroupBox1.InsertControl(RB);
RB.Width :=60;
RB.Left :=GroupBox1.ClientRect.Left+5 + Row*rb.Width ;
if (RB.Left +rb.Width )>=(GroupBox1.Width - 50 )then
begin
row:= 0 ;
Inc(col);
end
else
Inc(Row );
if i= 0 then Row := 0 ;
RB.Left:=GroupBox1.ClientRect.Left +5 +row*rb.Width ;
RB.Top :=GroupBox1.ClientRect.Top + 18 +col*rb.Height ;
ComboBox1.AddItem(Mlist[i],RB );
end;
end;
上面我已实现了把TRadioButton加到groupbox中,我下面]如何实现在combobox中选一项那一项就选中
Form1: TForm1;
RB:TRadioButton ;
implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
var
i:Integer ;
col:Integer ;
Row:Integer ;
Mlist:array[0..9]of string ;
begin
combobox1.Clear ;
col:=0;
Row:=0 ;
for i:=0 to 9 do
begin Mlist[i] :=IntToStr(i); RB:=TRadioButton.Create(self);
RB.Caption :=Mlist[i]; GroupBox1.InsertControl(RB);
RB.Width :=60;
RB.Left :=GroupBox1.ClientRect.Left+5 + Row*rb.Width ;
if (RB.Left +rb.Width )>=(GroupBox1.Width - 50 )then
begin
row:= 0 ;
Inc(col);
end
else
Inc(Row );
if i= 0 then Row := 0 ;
RB.Left:=GroupBox1.ClientRect.Left +5 +row*rb.Width ;
RB.Top :=GroupBox1.ClientRect.Top + 18 +col*rb.Height ;
ComboBox1.AddItem(Mlist[i],RB );
end;
end;
上面我已实现了把TRadioButton加到groupbox中,我下面]如何实现在combobox中选一项那一项就选中
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货