Z
zyr76
Unregistered / Unconfirmed
GUEST, unregistred user!
在窗体FormDirectTestCreate下想动态生成一个TGroupBox,但想在FormMain菜单项N_DirCreate下调用这个窗体后发现,窗体可以调用,但动态的GroupBox1没有显示,我的功能是要在出现这个窗体时动态生成GroupBox1,并在里面加入一些动态的TCheckBox等控件,奇怪的是这个代码(FormCreate下面)放在按钮的Click事件时却可以出现GroupBox1,请大家解答一下,如何在菜单项N_DirCreate下实现这个功能。
procedure TFormDirectTestCreate.FormCreate(Sender: TObject);
var
GroupBox1:TGroupBox;
begin
GroupBox1:=TGroupBox.Create(Self);
GroupBox1.Caption:='请选择试题类型和数量';
GroupBox1.Parent:=Self;
GroupBox1.Visible:=True;
GroupBox1.Height:=185;
GroupBox1.Width:=353;
GroupBox1.Top:=GroupBox2.Top+ GroupBox2.Height+10;
GroupBox1.Left:=GroupBox2.Left;
end;
--------------
procedure TFormMain.N_DirCreateClick(Sender: TObject);
var
aChildForm:TFormDirectTestCreate;
begin
aChildForm:=TFormDirectTestCreate.Create(Application);
aChildForm.ShowModal;
end;
procedure TFormDirectTestCreate.FormCreate(Sender: TObject);
var
GroupBox1:TGroupBox;
begin
GroupBox1:=TGroupBox.Create(Self);
GroupBox1.Caption:='请选择试题类型和数量';
GroupBox1.Parent:=Self;
GroupBox1.Visible:=True;
GroupBox1.Height:=185;
GroupBox1.Width:=353;
GroupBox1.Top:=GroupBox2.Top+ GroupBox2.Height+10;
GroupBox1.Left:=GroupBox2.Left;
end;
--------------
procedure TFormMain.N_DirCreateClick(Sender: TObject);
var
aChildForm:TFormDirectTestCreate;
begin
aChildForm:=TFormDirectTestCreate.Create(Application);
aChildForm.ShowModal;
end;