Dorababu Meka

Dorababu Meka

  • 227
  • 8.3k
  • 1.7m

Not opening in an MDI

Jun 22 2010 4:40 AM
Hi all,
              I have done an application using MDI. I have written a sample code to open form when i select a text file as follows

private void OpenFile(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            openFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                // TODO: Add code here to open the file.

                Form f = new form1();
                f.MdiParent = this.MdiParent;
                f.Show();
                string FileName = openFileDialog.FileName;
               
            }
        }
 
But i am unable to open that form inside MDI...  Can any one tell why

Answers (2)