private void 购买商品ToolStripMenuItem_Click(object sender, EventArgs e) { int all = 0, dingdan = 0; foreach (Form childrenForm in this.MdiChildren) { //检测是不是当前子窗体名称 if (childrenForm.Name == "all_goodsmessage") { all = 1; //是的话就是把他显示 childrenForm.Visible = true; //并激活该窗体 childrenForm.Activate(); //childrenForm.WindowState = FormWindowState.Maximized; break; } } foreach (Form childrenForm in this.MdiChildren) { //检测是不是当前子窗体名称 if (childrenForm.Name == "chuangjiandingdan") { dingdan = 1; //是的话就是把他显示 childrenForm.Visible = true; //并激活该窗体 childrenForm.Activate(); //childrenForm.WindowState = FormWindowState.Maximized; break; } } if (all == 0) { all_goodsmessage agm = new all_goodsmessage(); agm.MdiParent = this; agm.Show(); } if (dingdan == 0) { chuangjiandingdan cjdd = new chuangjiandingdan(); cjdd.MdiParent = this; cjdd.Show(); } LayoutMdi(MdiLayout.TileHorizontal);//水平排列子窗体 }
private void 所有商品ToolStripMenuItem_Click(object sender, EventArgs e) { foreach (Form childrenForm in this.MdiChildren) { //检测是不是当前子窗体名称 if (childrenForm.Name == "all_goodsmessage") { //是的话就是把他显示 childrenForm.Visible = true; //并激活该窗体 childrenForm.Activate(); //childrenForm.WindowState = FormWindowState.Maximized; return; } } all_goodsmessage agm = new all_goodsmessage(); agm.MdiParent = this; agm.Show(); }