您的位置:首页 > 其它

父窗体包含两个子窗体

2016-01-08 20:53 429 查看
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication18
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void showform(Form f)
{

int count = 0;
foreach (Form ff in this.MdiChildren)
{
if (f.Name == ff.Name)
{
ff.Focus();
count++;
}
}
if(count==0)
{
f.MdiParent = this;
f.Show();
}

}

private void 窗体一ToolStripMenuItem_Click(object sender, EventArgs e)
{
Form4 f = new Form4();
showform(f);

}

private void 窗体二ToolStripMenuItem_Click(object sender, EventArgs e)
{
Form5 f = new Form5();
showform(f);
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: