troubleshooting Question

Docking Form in a Panel

Avatar of creedence
creedence asked on
Visual Basic.NET
3 Comments1 Solution419 ViewsLast Modified:
I have a main form with a panel and three buttons. I have 3 other forms so when the user clicks button 1 on the main form, form 1 will display in the panel. When user clicks button 2, the panel clears and displays form 2. etc. I have tried this code in the buttons;

******************************************
Dim temp As New Form2

        pnlMain.Controls.Clear()          
        pnlMain.Controls.Add(temp
******************************************
 
however am getting error message "Top-level control cannot be added to a control." I have TopMost set to false in the forms I want to load. Can someone fix my code for me?



ASKER CERTIFIED SOLUTION
Munawar Hussain
Principal Software Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros