delphi 获取动态创建控件内容
遍历控件代码1:
var
i :Integer;
begin
for i := 0 to ComponentCount – 1 do
if Components[i] is TRadioButton then
if (Components[i] as TRadioButton).Checked then
begin
ShowMessage((Components[i] as TRadioButton).Caption);
Break;
end;
end;
遍历控件代码2:
procedure TForm1.btn1Click(Sender: TObject);
var
i:Integer
begin
for i:=0 to ComponentCount – 1 do
if Components[i] is TRadioButton then
TRadioButton(Components[i]).Caption
end;
或者动态创建时 设置控件的tag值 方便定位。