Search code examples
c#.netmdichildmdiparentvb.net-to-c#

C# creating MDI children WITHOUT MENU BAR


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.


Solution

  • 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.