主窗体属性设置IsMdiContainer=True显示子窗体时代码见下参考: private void 成品仓日报表ToolStripMenuItem_Click(object sender, EventArgs e)
{
InOut frmForm1 = new InOut();
ShowWindow(frmForm1);
} private void ShowWindow(Form frmForm1)
{
bool bOpen = false;
foreach (Form frmOpen in this.MdiChildren)
{
if (frmOpen.Name == frmForm1.Name)
{
frmOpen.Activate();
frmOpen.WindowState = FormWindowState.Maximized;
bOpen = true;
break;
}
}
if (bOpen == false)
{
frmForm1.MdiParent = this;
frmForm1.Show();
frmForm1.WindowState = FormWindowState.Maximized;
}
}
把主窗体的 IsMdiContainer 属性改为 True就可以了。
是在另一个窗体的内部显示吗?设置为MDI窗体就行了