父窗体的panel调用子窗体

纵饮孤独 提交于 2020-03-16 08:16:47

 private static Form1 form1;

private void toolStripButton1_Click(object sender, EventArgs e)
{
this.btnjkst.BackgroundImage = Image.FromFile(Application.StartupPath + @"\img\buttonanxia.jpg");
forma();
curform = "f1";
}
private void forma()
{
if (form1 == null || form1.IsDisposed)
{
Form1 sAllPage = new Form1();
sAllPage.TopLevel = false;
this.panel1.Controls.Clear();
this.panel1.Controls.Add(sAllPage);
sAllPage.Show();
sAllPage.WindowState = FormWindowState.Maximized;
sAllPage.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));

}
else
{
form1.Activate();
}
}

最大化是加这个

if (curform == "f1")
{
forma();
}

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!