I have a tree structure on one side. Depending on what node is selected, I want to display different content on the right. To preserve the managed code and controls, my plan was to isolate the content in separate forms and display the form inside the panel.
In my TreeView AfterSelect event, I tried to instantiate the form and set it to the parent, but I get an exception. "The top-level control cannot be added to the control."
Form frmShow = new MyForm();
frmShow.Parent = this.pnlHost;
This is not an MDI setting, but I tried setting the MdiParent property for the form to the parent form, and then setting the Parent property to the form, but I get an exception. "The form that was specified as MdiParent for this form is not an MdiContainer. Parameter name: value":
Form frmShow = new MyForm();
frmShow.MdiParent = this;
frmShow.Parent = this.pnlConfigure;
I cannot set the form as an MDI container, because it is not a top-level form, it is actually a form that dock within the parent form (using the WeifenLuo dock library).
Is there a way to parent form in a panel in an environment without MDI?
source
share