在博客园的 前沿速递 看了一篇 老地方,不一样的心情(在MDI窗体中显示子窗体的一个实例) ,按他的例子发现不是那么好用,结果自己查资料发现了这段代码:
private void ShowForm(string lFormName)
{
string tFormName = "testproj."+lFormName;
Form newMDIChild = (Form)Activator.CreateInstance(Type.GetType(tFormName));
newMDIChild.FormBorderStyle = FormBorderStyle.FixedToolWindow;
newMDIChild.WindowState = FormWindowState.Maximized;
newMDIChild.MdiParent = this;
// Display the new form.
newMDIChild.Show();
}
其中testproj是程序的命名空间,跟着下来的大家会做了吧!
来源
http://www.windowsforms.net/Forums/ShowPost.aspx?tabIndex=1&tabId=41&PostID=13688
![](https://img2024.cnblogs.com/blog/35695/202403/35695-20240328092537879-1189167464.jpg)