Question

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

Was it helpful?

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.

OTHER TIPS

Consider extracting the controls out of form1 into a UserControl. Use that UserControl on form1 (assuming you need it as a form as well as the docked control), then dock the UserControl on form2 to implement the desired functionality.

Consider using the COMPLETELY FREE docking library to develop Visual Studio .Net style applications provided by this link. Believe me, it's a commercial quality and bug-free code!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top