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
Not opening in an MDI
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Jaish MathewsRank #225 · 11K reputationPosted Jun 22, 2010, 2:46 AM EDT
If it's in side MDI, you need to change the below line
f.MdiParent = this;
Dorababu MekaRank #457 · 5.5K reputationPosted Jun 22, 2010, 2:50 AM EDT