procedure TForm1.Button1Click(Sender: TObject); //在生成 query1.recordcount个单选框
var pn:tradiogroup;
count1,j:integer;
begin
query1.Close;
query1.SQL.Clear;
query1.sql.Add('select * from 备用题库');
query1.ExecSQL;
query1.Active:=true;
count1:=query1.recordcount;
for j:=0 to count1 do
begin
pn:=tradiogroup.Create(scrollbox1);
pn.Parent:=scrollbox1;
pn.Left:=24;
pn.Width:=249;
pn.Height:=121;
pn.Top:=(j+1)*121+2;
end;
end;
procedure TForm1.Button2Click(Sender: TObject); //显示题目
var index,k:integer;
begin
k:=0;
for Index:=0 to scrollbox1.ControlCount-1 do
begin
query1.first;
query1.moveby(k);
if Components[Index] is TRadiogroup then
with (Components[Index] As TRadiogroup) do
begin
caption:=query1.FieldByName('题干').Asstring;
items.Add(query1.FieldByName('选项A').Asstring);
items.Add(query1.FieldByName('选项B').Asstring);
items.Add(query1.FieldByName('选项C').Asstring);
k:=k+1;
end;
end;
end;
可为什么最后显示题目时候,只有radiogroup1内显示题目内容呢? 动态生成的都没显示。 请指教