就是利用C#的反射技术:
例子,如下:
添加using System.Reflection;
private void button1_Click(object sender, EventArgs e)
{
string _textBox= "System.Windows.Forms.TextBox";
Type ctType = Assembly.LoadFrom(@"C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll").GetType(_textBox);
Control control = (Control)ctType.InvokeMember(null, BindingFlags.CreateInstance, null, null, null);
this.Controls.Add(control);
}
control 就是你想要的winFrom控件
或者
TextBox control = (TextBox)ctType.InvokeMember(null, BindingFlags.CreateInstance, null, null, null);
http://www.stuhack.com/biancheng/c_/7217.html,这篇文章应该能解开你的疑惑。