我希望使用标签访问一个TButton。
可能吗?
例如,我希望将TButton(button1的标签为3)的标题设置为“ aaa”,
我知道我可以用
button1.caption:='aaa';
但我希望使用标签“ 3”来访问tbutton并设置字符串值“ aaa”。
欢迎任何评论
谢谢
开发者
最佳答案
procedure TForm1.ChnCaptionByTag(SearchTag: integer; NewCpt: string);
var
i: Integer;
begin
for i := 0 to ComponentCount - 1 do
if Components[i] is TButton then
begin
if TButton(Components[i]).Tag = SearchTag then
TButton(Components[i]).Caption := NewCpt;
end;
end;
关于delphi - 是否可以使用标签访问TButton?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4510213/