dis_pro1: array[0..numcount] of TCheckBox;  //数组控件
窗体开始所有的Checkbox的Visible都为False,通过程序给它赋值,使他
的Caption。和Visible加以变化,但是程序运行到Dis_pro1[l].Visible :=true;( 错误出现在这个地方?) 就会出错,请大家告诉我是怎么回事呢?》

解决方案 »

  1.   

    if Dis_Pro1[1] <> nil then
    Dis_pro1[l].Visible :=true;
      

  2.   

    程序错误的提示信息是:‘Vclbp’Error
      

  3.   

    sql_str:='select cCheckItemName from checkitem where cgroupid='''+s2+''' ' ;
              WRYMain.OpenQuery(query2,sql_str);
              k1:=query2.RecordCount ;
              //for l:=6 to k1+5 do begin
           //     Dis_pro1[l]:= TCheckBox(FindComponent('CheckBox' + IntToStr(l)));
          //    end;
              first;
              l:=6;
              while not query2.eof do begin
                s3:=query2.fieldbyname('cCheckItemName').asstring;
                Dis_pro1[l]:= TCheckBox(FindComponent('CheckBox' + IntToStr(l)));
                Dis_pro1[l].Caption :=s3;
                if Dis_Pro1[l] <> nil then
                 Dis_pro1[l].Visible :=true ;
                 query2.next;
                l:=l+1;
              end;  s3明明有值,但是在执行dis-pro1[[l].caption:=s3的时候,却不能写入值,这是怎么回事呢?