将eidt1、edit2的tag属性分别指定为1、2
将eidt1、edit2的change事件指定为MyChange
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
procedure Mychange(Sender: TObject);
private
{ Private declarations }
public
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.MyChange(Sender: TObject);
begin
case TEdit(Sender).tag of
1:if Length(Edit1.Text)>10 then Edit2.SetFocus;
2:if Length(Edit1.Text)>10 then Edit2.SetFocus;
end
end;