本文介绍了使用MainForm和Panel制作子表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 根据此页 使用表格作为子表格 [ ^ ] i完全按页面描述 ,但处于两个子表单或更多子状态不工作 假设我有一个MenuStrip有两个toolStripMenuItem Page1和Page2 当我点击第1页时添加了一个subForm1但是当我点击Page2没有任何反应 ,因为SubForm2组件位于SubForm1组件后面 我如何告诉小组丢弃SubForm1并仅包含SubForm2 这是代码 private void page1ToolStripMenuItem_Click( object sender,EventArgs e) { Subform SubForm = new Subform(); SubForm.FormBorderStyle = FormBorderStyle.None; SubForm.TopLevel = false ; SubForm.ShowInTaskbar = false ; SubForm.Show(); SubForm.Dock = DockStyle.Fill; this .panel1.Controls.Add(SubForm); } private void page2ToolStripMenuItem_Click( object sender,EventArgs e) { subform1 SubForm = new subform1(); SubForm.FormBorderStyle = FormBorderStyle.None; SubForm.TopLevel = false ; SubForm.ShowInTaskbar = false ; SubForm.Show(); SubForm.Dock = DockStyle.Fill; 此 .panel1 = 新 Panel(); this .panel1.Controls.Add(SubForm); } 谢谢解决方案 According to this PageUse form as subform[^]i do exactly what the page describes but in the state of having two subforms or more it doesn't work suppose i have a MenuStrip having two toolStripMenuItem Page1 and Page2when i click Page 1 a subForm1 is added but when i click Page2 nothing happens because the SubForm2 Components Lies behind SubForm1 Components How can i tell the panel to discard SubForm1 and include only SubForm2here is the codeprivate void page1ToolStripMenuItem_Click(object sender, EventArgs e) { Subform SubForm = new Subform(); SubForm.FormBorderStyle = FormBorderStyle.None; SubForm.TopLevel = false; SubForm.ShowInTaskbar = false; SubForm.Show(); SubForm.Dock = DockStyle.Fill; this.panel1.Controls.Add(SubForm); } private void page2ToolStripMenuItem_Click(object sender, EventArgs e) { subform1 SubForm = new subform1(); SubForm.FormBorderStyle = FormBorderStyle.None; SubForm.TopLevel = false; SubForm.ShowInTaskbar = false; SubForm.Show(); SubForm.Dock = DockStyle.Fill; this.panel1 = new Panel(); this.panel1.Controls.Add(SubForm); }Thanks 解决方案 这篇关于使用MainForm和Panel制作子表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-27 16:18