我的程序中先动态生了一系列的edit控件,最后动态生成了一个button控件,button控件的事件与edit 控件有关,具体程序如下
a_credit:array[1..15] of tedit;
a_postbut:tbutton;
begin
a_credit[i]:=Tedit.create(self);
a_credit[i].Left:=..
a_credit[i].Text:='';
a_credit[i].Width:=40;
a_postbut:=Tbutton.Create(self);
a_postbut.Width:=150;
a_credit[i].Parent:=yuejuan;
a_postbut.Parent:=yuejuan;
a_postbut.OnClick:=a_postbutclick;
end;
对于 procedure a_postbutclick(sender:tobject)
过程是求出所有edit中的数字并求和,我想问的是这一个过程是否要声明?放在哪个位置好?我原来就是放在动态生成的过程中即在a_postbut.onclick:=a_postbutclick的后面了,但是好像不对。那应放在哪儿?如是放在动态生成控件过程的外面的话,那咱样传参数呢?
a_credit:array[1..15] of tedit;
a_postbut:tbutton;
begin
a_credit[i]:=Tedit.create(self);
a_credit[i].Left:=..
a_credit[i].Text:='';
a_credit[i].Width:=40;
a_postbut:=Tbutton.Create(self);
a_postbut.Width:=150;
a_credit[i].Parent:=yuejuan;
a_postbut.Parent:=yuejuan;
a_postbut.OnClick:=a_postbutclick;
end;
对于 procedure a_postbutclick(sender:tobject)
过程是求出所有edit中的数字并求和,我想问的是这一个过程是否要声明?放在哪个位置好?我原来就是放在动态生成的过程中即在a_postbut.onclick:=a_postbutclick的后面了,但是好像不对。那应放在哪儿?如是放在动态生成控件过程的外面的话,那咱样传参数呢?
放到那都可以
_postbut.OnClick:=a_postbutclick;
我也是这样想的呀,放在a_postbut.onclick:=a_postbutclick;的后面也行吗?但是每次都要报错:statement expected but 'procedure'found 好像是不应该放在这儿呀。
TForm1 = class(TForm)
..............
private
{ Private declarations }
public
{ Public declarations }
procedure aClick(Sender: TObject);
end;...........
Button2.OnClick := Form1.aClick;
begin //Add
//寫你要寫的 //Add
end; //Add
var //Add
a_credit:array[1..15] of tedit;
a_postbut:tbutton;
begin
a_credit[i]:=Tedit.create(self);
a_credit[i].Left:=..
a_credit[i].Text:='';
a_credit[i].Width:=40;
a_postbut:=Tbutton.Create(self);
a_postbut.Width:=150;
a_credit[i].Parent:=yuejuan;
a_postbut.Parent:=yuejuan;
a_postbut.OnClick:=a_postbutclick;
end;
yansea的也是一種很好的方法。一般的都是這么寫的﹐我寫的就是當這個procedure與全局沒有關系時﹐就可以這么寫。
那个a_postbutclick事件也是可以写在动态生成控件的过程中?好的我试一试,有问题再头号你们了,谢谢哟:)
有问题请发信息到我的E-mail:[email protected]
TForm1 = class(TForm)
..............
private
{ Private declarations }
public
{ Public declarations }
a_credit:array[1..15] of tedit;
procedure aClick(Sender: TObject);
end;procedure form1.aClick()...
var
i : integer;
begin
//判断a_credit是否创建
for i :=0 to 15
.....end;