Search code examples
c#formsdocking

Docking a form to another form panel


Is it possible to dock a form1 to a panel contained in another form2? I'm launching form1 with ShowDialog from a form2 event.


Solution

  • Not with ShowDialog (or even Show), no. A form that has already been displayed as a top-level form cannot later be added as a subcontrol of any other control. You can try to keep the form within a particular set of screen bounds by monitoring the LocationChanged event, but that will appear jerky on the screen.