怎么用foreach遍历CheckBoxList里的各项?

解决方案 »

  1.   

    // cs_foreach.cs
    class ForEachTest
    {
        static void Main(string[] args)
        {
            int[] fibarray = new int[] { 0, 1, 2, 3, 5, 8, 13 };
            foreach (int i in fibarray)
            {
                System.Console.WriteLine(i);
            }
        }
    }
      

  2.   

    lz是在说遍历CheckBoxList控件,楼上的是在访问数组lz可以使用for循环,比如:
                for (int n = 0; n < T1CheckBoxList.Items.Count; n++)
                {
                    T1 += Convert.ToString(n) + ":" + Convert.ToString(Convert.ToInt32(T1CheckBoxList.Items[n].Selected));
                    if (n < T1CheckBoxList.Items.Count - 1)
                    {
                        T1 += "|";
                    }
                }
      

  3.   

    foreach (CheckBox i in CheckBoxList)
            {
               ....
            }
      

  4.   

    foreach (ListItem li in CheckBoxList1.Items)
                    {
                        if (li.Selected==true)
                        { 
                        }
                    }
      

  5.   

    楼主
    'System.Windows.Forms.CheckedListBox'未实现 'GetEnumerator'。故不可以用foreach
    呵呵
    用for 循环吧。
      

  6.   

    jc15271149(嘿咻) ( ) 信誉:86    Blog  2006-10-18 15:19:00  得分: 0  
     
     
       foreach (ListItem li in CheckBoxList1.Items)
                    {
                        if (li.Selected==true)
                        { 
                        }
                    }///////////////////////////////////可用,高见
      
     
      

  7.   

    ok,问题解决,真快呀爱死csdn了