这样是否正确?
  if self.componts is Tcheckbox and Tcheckbox(componts[i]).checked then
    case Tcheckbox(componts[i]).tag of
       0:..........
       1:............
       2:......
    end;

解决方案 »

  1.   

    if (self.componts is Tcheckbox) and (Tcheckbox(componts[i]).checked) then
    最好加括号!
      

  2.   

    self.componts 错了,它是一个数组类型。  Self.Componts[i] is ***
      

  3.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      i : integer;
    begin
      for i := 0 to Self.ComponentCount - 1 do
      begin
        if (Self.Components[i] is TCheckBox) and (TCheckBox(Components[i]).Checked) then
          //do something here
      end;
    end;