如何将string转换为控件类型,或如何动态选择tform?(50分)

FINDCOMPONENT也许是你想要的:

function FindComponent(const AName: string): TComponent;

函数根据ANAME,返回名称为ANAME的控件。

Example:

findcomponent('FORM1').CAPTION:='hello';

 
使用方法函数
function TComponent.FindComponent(const AName: string): TComponent;

一般查询一个form中的控件 使用 form中自带的
FindComponent函数


查询一个form 一般使用Application变量中的
FindComponent函数

例子:

var
aform :TComponent;
begin
aform:=Application.FindComponent('form1') ;
if assigned(aform) then begin
try
with aform as TCustomForm do
show;
finally

end;
end;
end;
 
接受答案了.
 

Similar threads

D
回复
0
查看
746
DelphiTeacher的专栏
D
D
回复
0
查看
748
DelphiTeacher的专栏
D
D
回复
0
查看
595
DelphiTeacher的专栏
D
顶部