日期:2014-05-17  浏览次数:20714 次

怎么透过string形式的名称来访问某个控件?
例如:
string theName="textBox1";
theName.Text=.........; // 目的是想访问 textBox1 

------解决方案--------------------
 string theName = "textBox1";

            foreach (var item in this.Controls.Find(theName, false))
            {
                if (item is TextBox)
                {
                    TextBox tb = item as TextBox;
                    MessageBox.Show(tb.Text);
                    break;
                }
            }