Joseph

Joseph

  • NA
  • 12
  • 3.3k

MDI form project

Jun 19 2013 7:10 AM
i need to open a file in the  parent form then display it in the child form. i have a FORM1.cs file that opens the file, the opens the child window but i cant seem to understand how to show the text file contents in the child window.

I am doing this in the openToolStripMenuItem function. 

how can i get the value into the child form?

any suggestions would be greatly appreciated.

-----------------------------------code start -------------------------------------------

 private void openToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            OpenFileDialog ofdOpenFile = new OpenFileDialog();
            ofdOpenFile.Title = "Select a File To Open";
            ofdOpenFile.FileName = "";
            ofdOpenFile.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
            if (ofdOpenFile.ShowDialog() == DialogResult.OK)
            {
                RichTextBox rtb = GetRichTextBox();

                if (rtb == null)
                {
                  
                    FormChild fc = new FormChild();
                    fc.MdiParent = this;
                    fc.Show();
                  
                    string str = "dammit";
                    fc.Text = str;

                }

                if (rtb != null)
                {
                    rtb.LoadFile(ofdOpenFile.FileName, RichTextBoxStreamType.RichText);
                }
            }
        }

Answers (8)