请帮忙看一下!(30分)

  • 主题发起人 主题发起人 xy_c
  • 开始时间 开始时间
X

xy_c

Unregistered / Unconfirmed
GUEST, unregistred user!
我有一个form(里面已经 use datamodule),单独运行正常,但在由主程序这样调用
application.createform(tform1,form1);
form1.parent:=panel1;
form1.show;
之后,当要添加记录时,所有的数据敏感控件都好象被disable了,但如果form1.parent:=panel1去掉又正常,
请问该如何决解?
 
原因在于这句:application.createform(tform1,form1);
因为这是运行期动态创建的窗体,你在设计期设计那些控件不会生成的!
比如你想在form1上再显示Button1,这样用:
application.createform(tform,form1);
form2.parent:=panel1;
button1:=Tbutton.Create(self);
button1.Parent:=form1;
button1.caption:='ok';
button1.Left:=20;
button1.top:=20;
form2.show;

同样道理,你的数据敏感控件也要动态的创建才对!
例如
DBGrid1:=TDBGrid.Create(self);
DBGrid1.Parent:=form1; .....................等等
 
用Windows.SetParent(form1.Handle, panel1.Handle)替代form1.parent:=panel1;应该就行了。
 
我用Windows.SetParent(form1.Handle, panel1.Handle)
替代form1.parent:=panel1,但是在编译时form1.show这一句出错
提示为:‘missing operator or semicolon'
 
呵呵, 提示信息不是告诉你了吗?
没有分号。
 
我觉得为何要绕弯子用application.createform(tform1,form1);
直接
with TForm1.Create(Application) do
begin
parent:=panel1;
show;
end;
估计不会有问题。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部