public Child getChildForm1(int i)
        {
            Child form1 = new Child();
            TabPage tabPage = new TabPage();
            tabPage = tabControl1.TabPages[i];
            if (tabControl1.TabCount > 0)
            {
                foreach (Control c in tabPage.Controls)
                {
                    if (c.GetType() == typeof(Child))
                    {

                        Child form = c as Child;

                        return form;
                    }
                }
            }
            return form1;
        }
        public void 打开OToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog1.Title = "打开文件...";
            openFileDialog1.Filter = "富格式文件(*.rtf)|*.rtf|文本文件(*.txt)|*.txt|所有文件(*.*)|*.*";
            openFileDialog1.FilterIndex = 1;
            openFileDialog1.InitialDirectory = "桌面";
            openFileDialog1.ShowReadOnly = true;
            openFileDialog1.ReadOnlyChecked = false;
            openFileDialog1.FileName = "";

            Child child = new Child();
            child.setF1(this);
            //关键语句
            child.TopLevel = false;
            child.TopMost = false;
            child.ControlBox = true;
            child.FormBorderStyle = FormBorderStyle.None;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                int i = 0;
                Text = openFileDialog1.FileName;
                for (i = 0; i < tabControl1.TabCount; i++)
                {
                    Child child2 = getChildForm1(i);

                    if (openFileDialog1.FileName.Equals(child2.openFileDialog1.FileName))
                    {
                        break;
                    }
                }
                if (i == tabControl1.TabCount)
                {
                    RichTextBox f = child.getRichTextBox();

                    if (Path.GetExtension(openFileDialog1.FileName) == ".rtf")
                        f.LoadFile(openFileDialog1.FileName.ToString(), RichTextBoxStreamType.RichText);
                    else
                        f.LoadFile(openFileDialog1.FileName.ToString(), RichTextBoxStreamType.PlainText);

                    child.openFileDialog1.FileName = openFileDialog1.FileName.ToString();

                    TabPage newPage = new TabPage();

                    newPage.Text = openFileDialog1.SafeFileName.ToString();
                    newPage.Parent = tabControl1;
                    child.Parent = newPage;
                    child.Show();
                    tabControl1.SelectedTab = newPage;
                }
                else
                {
                    tabControl1.SelectedTab = tabControl1.TabPages[i];
                }
            }
            openFileDialog1.FileName = "";
        }
        private void 新建NToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog1.FileName = "";    //第一个在对话框中显示的文件或最后一个选取的文件,开始设置为空
            Child child = new Child();             //建立子窗口
            child.setF1(this);
            child.openFileDialog1.FileName = openFileDialog1.FileName; // 将现有属性添加到子窗口
            child.saveFileDialog1.FileName = saveFileDialog1.FileName;

            //关键语句
            child.TopLevel = false;
            child.TopMost = false;
            child.ControlBox = true;
            child.FormBorderStyle = FormBorderStyle.None;
            child.Dock = DockStyle.Fill;
            TabPage newPage = new TabPage();
            tabNum += 1;     //标签数加1

            newPage.Text = "未命名 " + tabNum.ToString();
            newPage.Parent = tabControl1;
            child.Parent = newPage;
            child.Show();
            tabControl1.SelectedTab = newPage;
        }