delphi 中,动态生成的edit 控件问题?

来源:百度知道 编辑:UC知道 时间:2024/05/19 00:22:26
edit控件是动态生成的,我如何给它创立一个事件
例如:
在程序运行时创建了5个edit控件,当我给生成的第一个edit控件输入内容后,退出时,就触发一个事件。
该如保编写呢?

急盼

不太清楚你说什么,我的理解是:动态生成edit控件,然后,你要编辑动态生成的edit的内容,最后在退出主程序(或edit的parent)时,触发一个事件。

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;

type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
myedit:Tedit;
implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
myedit:=Tedit.Create(application);
myedit.Parent:=self;
myedit.Top:=10;
myedit.Left:=10;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if myedit.Text<>'' then//如果myedit不为空,就响一下,并showmessage;
begin
bee