delphi 界面中点击按钮创建的窗体为什么在FormCreate中初始化代码?

2025-05-10 15:39:05
推荐回答(4个)
回答1:

form1中uses unit2而后
var
Form1: TForm1;
afm:Tform2;//添加这个
implementation

{$R *.dfm}

procedure TForm1.Edit1Click(Sender: TObject);
begin
afm:=Tform2.Create(self);
afm.Edit1.text:='Form_Edit1';
afm.Caption:='Form_edit1';
afm.ShowModal;
end;

procedure TForm1.Edit2Click(Sender: TObject);
begin
afm:=Tform2.Create(self);
afm.Edit1.text:='Form_Edit2';
afm.Caption:='Form_edit2';
afm.ShowModal;
end;
form2中添加个button、edit、dbgrid、adoquery、datasource、adoconnect各一个,在form2中设置好它们相关属性;
procedure TForm2.Button1Click(Sender: TObject);
begin
with adoquery1 do
begin
close;
sql.clear;
sql.text:='select * from tb_1 where field_1='''+edit1.Text +'''';
open;
end;
end;
测试通过.........

回答2:

代码肯定是错的

回答3:

一方面

回答4:

不明白意思....