怎样遍历Form中所有自动生成的CheckedListBox(急)
如题:   
 怎样遍历Form中所有自动生成的CheckedListBox   
 遍历想查看每个CheckedListBox有多少被选中,多少没选!   
 请各位帮忙   开解
------解决方案--------------------foreach (CheckBox cb in Form.Controls) 
             { 
                 if (cb.Checked) 
                 { 
                     selectTypeCount++; 
                 } 
             } 
             if (selectTypeCount == 0) 
             { 
                 error.SetError(groupBox1,  "请至少选择一种图片类型 "); 
             } 
             else 
             { 
                 error.SetError(groupBox1,  " "); 
             }   
 本人的程序代码。我用的是CheckBox,你用的是CheckedListBox,我想这个不难改成你希望的代码。
------解决方案--------------------我以前是这样解决的,改变控件的外观,稍加修改应该适用于你的要求,不知道有没有更好的办法。   
 foreach (Control c in this.Controls) 
 { 
     string s = c.GetType().ToString(); 
     switch (s) 
     { 
         case  "System.Windows.Forms.Button ": 
             { 
                 Button b = (Button)c; 
                 if (b.FlatStyle == FlatStyle.Flat) 
                 { 
                     b.FlatStyle = FlatStyle.Standard; 
                 } 
                 else 
                 { 
                     b.FlatStyle = FlatStyle.Flat; 
                 } 
                 break; 
             } 
         case  "System.Windows.Forms.TextBox ": 
             { 
                 TextBox t = (TextBox)c; 
                 if (t.BorderStyle == BorderStyle.FixedSingle) 
                 { 
                     t.BorderStyle = BorderStyle.Fixed3D; 
                 } 
                 else 
                 { 
                     t.BorderStyle = BorderStyle.FixedSingle; 
                 } 
                 break; 
             } 
     } 
 }
------解决方案--------------------public class Form1 : Form 
     { 
         private GroupBox groupBox1; 
         private CheckedListBox checkedListBox2; 
         private GroupBox groupBox2; 
         private CheckedListBox checkedListBox3; 
         private CheckedListBox checkedListBox1; 
         private TextBox textBox1; 
         ///  <summary>  
         /// 必需的设计器变量。 
         ///  </summary>  
         private System.ComponentModel.IContainer components = null; 
         private Label label1;   
         ///  <summary>  
         /// 找到CheckedListBox的数量 
         ///  </summary>  
         private int m_ctrlCount;   
         ///  <summary>  
         /// 清理所有正在使用的资源。 
         ///  </summary>  
         ///  <param name= "disposing "> 如果应释放托管资源,为 true;否则为 false。 </param>  
         protected override void Dispose(bool disposing) 
         { 
             if (disposing && (components != null)) 
             { 
                 components.Dispose(); 
             } 
             base.Dispose(disposing); 
         }   
         #region Windows 窗体设计器生成的代码   
         ///  <summary>  
         /// 设计器支持所需的方法 - 不要 
         /// 使用代码编辑器修改此方法的内容。 
         ///  </summary>  
         private void InitializeComponent() 
         { 
             this.groupBox1 = new System.Windows.Forms.GroupBox(); 
             this.groupBox2 = new System.Windows.Forms.GroupBox(); 
             this.checkedListBox1 = new System.Windows.Forms.CheckedListBox(); 
             this.checkedListBox2 = new System.Windows.Forms.CheckedListBox(); 
             this.checkedListBox3 = new System.Windows.Forms.CheckedListBox();