SplitContainer's panel as the MDI parent for other forms

这一生的挚爱 提交于 2019-12-13 12:24:20

问题


I have got a control with a Splitcontainer added. I want to place another forms on the second panel (Panel2). However, it is not possible to set the MDIParent property of a brand new form to Panel2.

Thus, the question is - how can I set the SplitContainer's panel as the MDIParent for another controls?

Thank you in advance for the clues!

cheers


回答1:


An MDIParent can only be another Form. What you need to do is set TopLevel to False on the child Form. Then you can add it to any control just like it was any other control (by adding it to the parent control's Controls collection). However, it won't work like it does in an MDI container (as in you won't be able to minimize or maximize it).




回答2:


If you want to make Panel-Splitter-MdiClient Form see panel and MDI in c#




回答3:


If your intent is to use the splitcontainer to load different subforms this may help. Instead of using WinForms, you could use classes derived from panels containing all the widgets that a normal WinForm would have. To display them, simply add them to your splitcontainer's Panel2 controls collection.

Some events and methods to keep in mind are:

  • subformPanel.ParentChanged (do some initialization and subscribe to any parent events)
  • subformPanel.ParentChanged (do some cleaning up and unsubscribe to parent events)
  • Parent.Controls.Remove (destroy the subformPanel)


来源:https://stackoverflow.com/questions/4230486/splitcontainers-panel-as-the-mdi-parent-for-other-forms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!