开发者

SplitContainer's panel as the MDI parent for other forms

开发者 https://www.devze.com 2023-01-26 14:52 出处:网络
I have got a control with a Splitcontainer added. I want to place anot开发者_如何学Goher forms on the second panel (Panel2). However, it is not possible to

I have got a control with a Splitcontainer added. I want to place anot开发者_如何学Goher 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


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


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


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)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号