如何通过反射动态地(根据用户的选择)加载控件
比如,在界面上我输入TextBox,点击按钮就生成一个TextBox,输入...,点击按钮则生成...
[解决办法]
请参考:
Control c ;
c = (Control)System.Activator.CreateInstance(Type.GetType( "System.Windows.Forms. " + textBox1.Text + ", System.Windows.Forms, version=1.0.5000.0, culture=neutral, publickeytoken=b77a5c561934e089 "));
c.Name = str;
c.Size= new Size(168, 40);
c.Location= new Point(64, 176);
this.Controls.Add(c);