我做了两个控件组 代码如下 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;如何让 btn[*]按下的时候 对应的mmo[*]有响应呢 。
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;如何让 btn[*]按下的时候 对应的mmo[*]有响应呢 。
SetLength(Btnmmo,100);
a:=a+1;
Btnmmo[a].Button:=TButton.Create(self);
Btnmmo[a].Button.Parent:=Self;
Btnmmo[a].Button.Caption:='111';
Btnmmo[a].Button.Top:=a*50;
Btnmmo[a].Button.OnClick:=btnClick;
Btnmmo[a].Memo:=TMemo.Create(self);
Btnmmo[a].Memo.Parent:=Self;
Btnmmo[a].Memo.Top:=a*40;
Btnmmo[a].Memo.Left:=100;
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;
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;
Bear_hx 的没看懂了 。