Form1里有一个button1,Form2里有一个Edit1,
现想按下Form1里的button1后,Form2里的Edit1的Text变为‘hello’,
请问button1的触发事件怎么写?
我用了Form2.edit1.text:='hello';
好像不行啊,
谢谢
现想按下Form1里的button1后,Form2里的Edit1的Text变为‘hello’,
请问button1的触发事件怎么写?
我用了Form2.edit1.text:='hello';
好像不行啊,
谢谢
解决方案 »
- TDBGrid简单问题,急
- FastReport的奇怪问题,在线等待
- 请教:任何实现这样一个通知系统
- 郁闷!!!!!!!!!!!!!!!!!!!!散分。。。。。。。。
- 急急急!高分相送。!关于动态创建的图形选定
- 关于设计数据库的问题,请高手指教?
- 在一个明细表中增加一个计算字段显示记录的序号
- 用InstallShield打包时,怎样才能知道应用程序需要的所有包文件和动态链接库文件!
- 关于DElPHI中调用VC++编写的DLL的问题。(50分)
- HINT 的字体怎么设??????????
- 急救!关于SQL语句,大鸟们帮帮忙!
- DBGrid的问题,如何在提交记录后在DBGrid中能立即反映出来(请各位高手指点)
可以的,只要你在form1的implementation 下写:uses unit2;就可以了。
procedure TForm1.Button1Click(Sender: TObject);
begin
Form2.Edit1.Text :='hello';
form2.Show;
end;
var strPost:string;
button1click
begin
strPost:=1;
end;
form2中
if strPost=1 then
edit1.text:='hello!'
2、若使用菜单项中的file项中的use unit项进行引用。
经过这样以后就可以直接使用你的方法进行赋值了!
首先new一个新的工程,然后再新建一个是form,进入project菜单,单击其中的option菜单后进入,使form2成为不自动创建(方法为:在auto-create forms中选中form2,然后双击即可,单击ok按钮)。
此程序的原理是通过在密码窗体(运行时首先显示此窗体)输入的密码文本是否和主窗体中的edit中的文本一样,如果一样就进入程序,否则退出程序。
在form1,form2中各加一个eidt控件,然后在form2中加入一个button控件。
程序源码如下:
工程文件:
program Project1;uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2};{$R *.RES}begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
form2:=tform2.create(application);
form2.showmodal;
if (text1<>form1.edit1.text) then
begin
application.Terminate;
end;
Application.Run;
end.单元1文件
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Edit1: TEdit;
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}end.
单元2文件
unit Unit2;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm2 = class(TForm)
Edit1: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form2: TForm2;
text1:string;
implementation{$R *.DFM}procedure TForm2.Button1Click(Sender: TObject);
begin
text1:=form2.edit1.text;
form2.close;
end;end.