这段delphi代码问题在哪?

来源:百度知道 编辑:UC知道 时间:2024/05/04 11:30:43
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
procedure buttonclick(sender:Tobject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
procedure TForm1.buttonclick(sender:Tobject);
begin
if sender=button1 then
form1.Label1.Caption :='阳春白雪'
else
form1.label2.Caption :='下里巴人';
end;
点button1/2桌面上无动于衷。

unit Unit1;

interface

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

type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
if sender=button1 then
form1.Label1.Caption :='阳春白雪'
else
form1.label2.Caption :='下里巴人';
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
button2.OnClick:=button1.OnClick;
end;

end.

有反映

可能你的代码是copy过去的吧,虽然你的代码反映的是button的OnClick