//窗体A 动态创建一个edit控件
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
btn1: TButton;
procedure btn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
texta:string;
end;
var
Form1: TForm1;
implementation
uses
Unit2;
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
begin
Form2.ShowModal;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
edt:TEdit;
begin
edt:=TEdit.Create(Form1);
edt.Parent:=Form1;
edt.Top:=100;
edt.Left:=100;
edt.Name:='edt_test';
end;
end.
//窗体B
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
edt1: TEdit;
btn1: TButton;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses
Unit1;
{$R *.dfm}
procedure TForm2.btn1Click(Sender: TObject);
begin
//如何查找A窗体中指定edit控件,并将B窗体中的edit的text值赋给A窗体上的edit控件。
end;
end.