I have a form with a treeview on one side. Depending on what node is selected, I want to display different content on the right. To keep code and controls manageable, my plan was to isolate content into seperate forms, and display the form inside a panel.
In my TreeView AfterSelect event, I tried instantiating the form, and setting it's Parent to a panel but I get an exception "Top-level control cannot be added to a control.":
Form frmShow = new MyForm();
frmShow.Parent = this.pnlHost;
This is not an MDI configuration, but I tried setting the forms MdiParent property to the parent form, and then setting the form's Parent property to the panel but I get an exception "Form that was specified to be the MdiParent for this form is not an MdiContainer. Parameter name: value":
Form frmShow = new MyForm();
frmShow.MdiParent = this;
frmShow.Parent = this.pnlConfigure;
I can't set the form as an MDI Container because it is not a top level form, it is actually a form that is docked inside a parent form (using the WeifenLuo docking library).
Is there some way to parent a form in a panel in a non MDI framework?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…