在winform里,如何在groupbox里面循环获得所选取的checkbox的值。并且把他保存在数组里。
读取的时候,能根据索引读取值。直接插入到数据库里。 
能够一个一个单独的把值给读取出来。
给个具体的代码。谢谢。

解决方案 »

  1.   

    bool[] states =new boo[checkbox的数量];
    int i=0;foreach(Control c in this.groupBox1)
    {
       if(c.GetType()==typeof(CheckBox))
       {
          states[i]=c.Checked;
          i++;
       }
    }
      

  2.   

    foreach(Control c in this.groupBox1.Controls) 好像是这样的吧
      

  3.   

    bool[] states =new boo[checkbox的数量]; 
    int i=0; foreach(Control c in this.groupBox1) 

      if(c is CheckBox)
      { 
          states[i]=c.Checked; 
          i++; 
      } 
      

  4.   

    List<string> list=new ArrayList<string>foreach(Control c in this.groupBox1.Controls)
    {
    if(c is CheckBox) 
      { 
          if(((CheckBox)c).Checked)
              list.add(c.Text);
      } 
    }