string name="S002";
//我有个CheckBox的Name是S002,我想在运行时通过反射来获取该控件并设置S002.Check=true;

解决方案 »

  1.   

    不可以使用FindControl方法么?
      

  2.   

    哦,我的是Winform,好像没有FindControl方法啊
      

  3.   


    foreach (Control c in this.Controls)
                {
                    if (c is CheckBox)
                    {
                        CheckBox cc = c as CheckBox;
                        if (cc.Name == "")
                        {
                            cc.Checked =  true;
                        }
                    }
                }