2
Reply

Not opening in an MDI

Ask a question
Dorababu Meka

Dorababu Meka

14y
2.5k
1
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)