if (Self.Controls[n].ClassName='TCheckbox') and (tcheckbox(Self.Controls[n]).Checked =true) then
      begin
       m:=m+1 ;
      end;
这一句:
if (Self.Controls[n].ClassName='TCheckbox') and (tcheckbox(Self.Controls[n]).Checked =true) then
为什么总是假?下面的语句:
      begin
       m:=m+1 ;
      end;
总是无法执行到呢?!:(
能解说一下Self.Controls[n].ClassName吗??可不可以直接统计checkbox被选中的个数呢?

解决方案 »

  1.   

    if (Self.Controls[n].ClassName='TCheckBox')  //'TCheckBox' 
    and (tcheckbox(Self.Controls[n]).Checked =true) then
      

  2.   

    if CompareText(Self.Controls[n].ClassName, 'TCheckbox') = 0————————————————————————————————————
    宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
    ————————————————————————————————————
      

  3.   

    if (Self.Controls[n] is TCheckbox) and (tcheckbox(Self.Controls[n]).Checked) then
    begin
      m:=m+1 ;
    end;
      

  4.   

    老将出马,一个顶两,按照我写的来,成功后记得给分啊。  
      if (Self.Components[i] is TCheckBox) and TCheckBox(Self.Components[i]).Checked then
           m:=m+1;
      

  5.   

    if (Self.Components[i] is TCheckBox) and (Self.Components[i] as TcheckBox).Checked then
           m:=m+1;
      

  6.   

    應採用
    if (Self.Controls[n].ClassName is TCheckbox) then
    begin
     if Tcheckbox(Self.Controls[n]).Checked then
        M := M + 1 ;
    end;
      

  7.   

    你大小写没注意
    CheckBox的ClassName 为TCheckBox
    不是TCheckbox
      

  8.   

    还是不行!是不是我的程序有问题?下面是这一段代码,请大家指教!!!
    for i:=0 to self.ControlCount-1 do
      begin
         if self.controls[i].className='TCheckBox' then
         begin
            if TCheckBox(Self.controls[i]).Checked  then
             m:=m+1;
         end;
      end;