I've just switched from using .NET and VB to using C# instead and I am having hard time creating an MDI child that loads automatically with it's parent. So I have a parent form (with IsMdiContainer = True). I also have another windows form which I would like to assign as being a child to the main parent and have it load upon initial loading of the parent. In VB this was extremely simple; in the Mdiparent you simply said form1.mdiParent = Me (more or less) and form1.Show() to get it to load alongside the parent. Is there a way to do this in C#? Every help page I look at requires making the children dynamically with a menu bar and this is not something I want to do. Any help? Sorry if this question has been asked before; I searched high and low before asking.
Asked
Active
Viewed 799 times
-2
-
3Have you tried something along the lines of.. `form1.MdiParent = this; form1.Show();`? – Quintin Robinson Nov 15 '12 at 22:52
-
2As @QuintinRobinson implicitly points out, this isn't an MDI question, but a how-do-I-do-in-C#-what-I-already-know-in-VB question. .NET is .NET, whether VB or C# - the language doesn't change what you know how to do, just how you say it. ;) – prprcupofcoffee Nov 15 '12 at 22:58
-
Normally I would do what Quintin has suggested; however when I type in leftPanel.MdiParent, it says there is no definition for MdiParent, like it isn't a recognized command. Is there a 'using' that I need to include? – tmwoods Nov 15 '12 at 23:40
-
For that matter I also can't use the show command, close, etc. – tmwoods Nov 15 '12 at 23:51
1 Answers
0
So I screwed around for a long time before figuring this one out. I had to declare an instance of the object first apparently.
This is what I have now which works:
private void mainParent_Load(object sender, EventArgs e)
{
leftPanel LP = new leftPanel();
LP.MdiParent = this;
LP.Show();
}
I hope this helps anyone else who runs into the same problem. That first line in the brackets is really the money I was missing.

tmwoods
- 2,353
- 7
- 28
- 55