实际上它是我的第一个项目。虽然我想将我的 VB.Net2008 转换为 C#2010,但我几乎没有澄清。
在Form2
我设置的属性中 - IsMDIContainer = True
。然后下面的代码打开我的MdiChild
,现在当我点击关闭按钮时我的问题是什么,它也在关闭MDIParent
. 但我只需要关闭 mdichild ... 为此我尝试通过放置在以下代码中的 Vb.Net2008 样式,但MDIParent
Form2
它不起作用。任何正确的方向...
private void toolStripButton1_Click(object sender, EventArgs e)
{
Form3 NwMdiChild2 = new Form3;
NwMdiChild2.MdiParent = this;
NwMdiChild2.Dock = System.Windows.Forms.DockStyle.Fill;
NwMdiChild2.Show();
}
private void Form2_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e)
{
Form[] MdiChildForms = this.MdiChildren;
int kkk1 = MdiChildForms.Length;
int x = 0;
for (x = 0; x <= MdiChildForms.Length - 1; x += 1)
{
if (MdiChildForms[x].Name == "Form1")
{
kkk1 = kkk1 - 1;
}
MdiChildForms[x].Close();
}
if (kkk1 > 0)
{
// For Not Closing
e.Cancel = true;
}
else
{
// For Closing
e.Cancel = false;
Application.Exit();
}
}
对我有什么正确的方向吗?