在Delphi.Net中
type
TForm1 = class (TForm)
Edit1: TEdit;
Button1: TButton;
protected
procedure Button1Click(Sender: TObject;
Args: TEventArgs);
public
constructor Create;
end;
{...}
procedure TForm1.Button1Click(Sender: TObject;
Args: TEventArgs);
begin
MessageBox.Show('您输入的是'#$A#$D + Edit1.Text , '测试');
end;
constructor TForm1.Create;
begin
{...}
with Button1do
begin
Name := 'Button1';
Top := 10;
Left := 130;
Width := 70;
Height := 28;
Text := 'Show!';
add_Click( Button1Click );
//增加事件
end;