见代码:
void DynamicControl(string tag,string ctrType)
{
string assName = typeof(System.Windows.Forms.Form).AssemblyQualifiedName;
string assInfo = assName.Substring(assName.IndexOf(","));
Type type = System.Type.GetType("System.Windows.Forms." + ctrType + assInfo, true);
Control ctrl = (Control)Activator.CreateInstance(type);
Type t = ctrl.GetType();
t.InvokeMember("Tag", BindingFlags.SetProperty, null, ctrl, new object[1] { tag });
t.InvokeMember("Name", BindingFlags.SetProperty, null, ctrl, new object[1] { name });
t.InvokeMember("Text", BindingFlags.SetProperty, null, ctrl, new object[1] { "Test" });
this.Controls.Add(ctrl);
}