type
TMyEdit=class(TEdit)
private
F_MainEdit:TEdit;
protected
procedure Change;override; //控件内容改变时触发OnChange事件
public
property MainEdit:TEdit read F_MainEdit write F_MainEdit; //记录主窗体Edit指针
end;
procedure TMyEdit.Change;
begin
if Assigned(F_MainEdit) then F_MainEdit.Text:=Self.Text;
end;
--------------------------------------------
//初始化
var MyEdit:TMyEdit;
begin
MyEdit:=TMyEdit.Create(MainWin);
MyEdit.MainEdit:=MainWin.Edit;
end;
//当MyEdit的Text发生变化,则MainWin的Edit的Text也变化