var myFrame:array of TInvFrame;
    i:integer;
begin
SetLength(myframe,3);
for i:=0 to 2 do
  begin
     myframe[i]:=TInvframe.Create(self);
       with myframe[i] do
         begin
         Parent:=self;
         Height:=1000;
         if i>0 then
         Top:=myframe[i-1].Top+1000;
  end;
end;请各位高手指教一下!为何写这样的控件数组老是会报错,提示TInvframe这个TFrame已经存在!如何解决这个问题?

解决方案 »

  1.   

    我以前也碰到过,主要是名字问题,Delphi开发小组没有设想到这个问题
    var myFrame:array of TInvFrame;
        i:integer;
    begin
    SetLength(myframe,3);
    for i:=0 to 2 do
      begin
         myframe[i]:=TInvframe.Create(self);
           with myframe[i] do
             begin
             name := Format('myframe%d'); //赋予不同的名字
             Parent:=self;
             Height:=1000;
             if i>0 then
             Top:=myframe[i-1].Top+1000;
      end;
    end;