我的程序大概如下:
 for i:=0 to n  do
       cheader:=Tqrlabel.create(qrlistform.QuickRep1);
         with qrlistform do
          begin
             cheader.Parent:=qrlistform.ColumnHeaderBand1;
             cheader.Caption:=a[i];
             cheader.Width:=(ColumnHeaderBand1.width div n);
             cheader.Height:=ColumnHeaderBand1.Height;
             top:=2;
          end;
    。
    。
    。
    。
  
   for i:=1 to n-1 do
     begin
       shap:=Tqrshape.create(qrlistform.DetailBand1);
         with qrlistform do
          begin
             shap.Parent:=qrlistform.DetailBand1;
             shap.Width:=1;
             shap.Height:=qrlistform.DetailBand1.Height;
             shap.Left:=leftv+((ColumnHeaderBand1.width div n)*(i))-5;
             top:=0;
          end;
     end ;
   qrlistform.QuickRep1.Preview;
   shap.Free;
   detailtext.Free;
   cheader.Free;
但是再次运行时它就有上一次所创建的东西,什么才能把上一次所有所创建的都弃放掉呢??

解决方案 »

  1.   

    1 shap   detailtext   cheader都用控件数组
    2 释放使用FreeAndNil
      

  2.   

    把form freeandnil掉再次调用时重新建立
      

  3.   

    你创建了多少个就释放多少个, 你创建那么多Shape, 你只释放掉了一个
    要不直接把窗体释放掉更好了
      

  4.   

    如你的方法,其实,只是释放了最后一个创建的控件.
    最好,你将整个窗口都释放掉,再用时重新建立!
    要么,你也可用
    var i: integer;for i:=0 to ComponentCount-1 do
     FreeAndNil(Components[i]);将所有创建的控件释放!!
      

  5.   

    我做过这方面的,你只释放了最后一个,你只有用for i:=0 to ComponentCount-1 do
    遍历所有控件,检查到你创建的,你就释放掉
      

  6.   

    释放掉form,然后重新创建比较简单