【发布时间】:2014-02-21 01:33:58
【问题描述】:
我有这样的程序在 TForm 上显示/隐藏一个元素:
procedure ShowHideControl(const ParentForm: TForm; const ControlName: String; ShowControl: Boolean);
var
i: Integer;
begin
for i := 0 to pred(ParentForm.ComponentCount) do
begin
if (ParentForm.Components[i].Name = ControlName) then
begin
if ShowControl then
TControl(ParentForm.Components[i]).Show
else
TControl(ParentForm.Components[i]).Hide;
Break;
end;
end;
end;
然后我尝试像这样使用它:
procedure TForm1.Button6Click(Sender: TObject);
begin
ShowHideEveryControl(TForm(TForm1), 'Button4', True);
end;
为什么点击 Button6 时会出现访问冲突?
对我来说一切都很好...... Button4 作为一个孩子存在 :)
【问题讨论】:
标签: delphi