5,392
社区成员
发帖
与我相关
我的任务
分享
SetLength(Btn,100);
SetLength(mmo,100);
a:=a+1;
Btn[a]:=TButton.Create(self);
Btn[a].Parent:=Self;
Btn[a].Caption:='111';
btn[a].Top:=a*50;
btn[a].OnClick:=btnClick;
mmo[a]:=TMemo.Create(self);
mmo[a].Parent:=Self;
mmo[a].Top:=a*40;
mmo[a].Left:=100;
t:='Bt'+edt1.Text;
m:='Mo'+edt1.Text;
SetLength(Btn,100);
SetLength(mmo,100);
a:=a+1;
Btn[a]:=TButton.Create(self);
Btn[a].Parent:=Self;
Btn[a].Caption:='111';
btn[a].Top:=a*50;
btn[a].OnClick:=btnClick;
Btn[a].Name:=t;
mmo[a]:=TMemo.Create(self);
mmo[a].Parent:=Self;
mmo[a].Top:=a*40;
mmo[a].Left:=100;
mmo[a].OnClick:=mmoClick;
mmo[a].Name:=m;
SetLength(Btn,100);
SetLength(mmo,100);
a:=a+1;
Btn[a]:=TButton.Create(self);
Btn[a].Parent:=Self;
Btn[a].Caption:='111';
btn[a].Top:=a*50;
btn[a].OnClick:=btnClick;
btn[a].Tag:=a; //关联一下
mmo[a]:=TMemo.Create(self);
mmo[a].Parent:=Self;
mmo[a].Top:=a*40;
mmo[a].Left:=100;
在BtnClick事件中写
if High(mmo)<Sender.Tag then exit; //判断是否越界
if Assigned(Mmo[Sender.Tag) then //如果存在,则
begin
with Mmo[Sender.Tag] do
begin
//进行处理
end;
end;