***************我动态创建的EDIT,怎么给他加 OnChange事件
http://www.delphi2007.net/DelphiDB/html/delphi_20061216164404267.html
我动态创建的EDIT,怎么给他加 OnChange事件
写个事件付值给它
procedure EditChange(Sender: TObject);
begin
showmessage(Tedit(Sender).text);
end;
var NewEdit:Tedit;
begin
NewEdit:=Tedit.Create(self);
NewEdit.Parent:=self;
NewEdit.SetBounds(10,20,50,21);
NewEdit.OnChange:=EditChange;
end;
楼上写的基本正确,但稍微有些问题:
procedure TForm1.EditChange(Sender: TObject);
begin
showmessage(Tedit(Sender).text);
end;
procedure TForm1.EditChange(Sender: TObject);
begin
showmessage(Tedit(Sender).text);
end;
procedure TForm1.Button1Click(Sender: TObject);
var NewEdit:Tedit;
begin
NewEdit:=Tedit.Create(nil);
NewEdit.Parent:=self;
NewEdit.SetBounds(10,20,50,21);
NewEdit.OnChange:=EditChange;
end;
delphi 学习群:31469235
加入请注明 csdn 字样