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();
}
来源:https://www.cnblogs.com/lmcblog/archive/2012/07/25/2608618.html