示例#1
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmChild child = new frmChild();

            child.MdiParent = this;
            child.Show();

            Form activeChild = this.ActiveMdiChild;

            if (activeChild != null)
            {
                RichTextBox theBox = (RichTextBox)activeChild.ActiveControl;
                if (theBox != null)
                {
                    // Create an OpenFileDialog to request a file to open.
                    OpenFileDialog openFile1 = new OpenFileDialog();

                    // Initialize the OpenFileDialog to look for RTF files.
                    openFile1.DefaultExt = "*.rtf";
                    openFile1.Filter     = "RTF Files|*.rtf|Text files (*.txt)|*.txt|All files (*.*)|*.*";

                    // Determine whether the user selected a file from the OpenFileDialog.
                    if (openFile1.ShowDialog() == DialogResult.OK &&
                        openFile1.FileName.Length > 0)
                    {
                        // Load the contents of the file into the RichTextBox.
                        theBox.LoadFile(openFile1.FileName, RichTextBoxStreamType.PlainText);
                        child.Text = openFile1.FileName;
                    }
                }
            }
        }
示例#2
0
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmChild child = new frmChild();

            child.Text      = "Untitled " + Count;
            child.MdiParent = this;
            child.Show();
            Count++;
        }