I am new to C#.Net.
I have a form with some panels in it. One of the panels is MainPanel. After start up, the MainPanel is empty. Based on user selection, I want to load some controls in it. Something similar to CardLayout in Java! Each panel have a lot of Controls and I don't want to add them programatically. In fact the question is "Is there a way to have some panels designed in designer and show/hide them based on user selection, all in one form?"
Thank you.
Best Answer
Yes, create new objects called UserControls in their own classes. You can add and remove them programmatically, but create them in the designer.
To keep from getting flicker when changing the controls, do something like the following:
Create your User Controls, and name them whatever you wish, I'll make some names up now for examples:
Add those 5 files as UserControls to your project. Design them however you want.
Create an enum for the different buttons for ease of use:
Once you have them created, in the button click events for each of those buttons, add a call to this new method:
Then in your button click events, you could have something like this:
The same thing would be in the other click events, just change out the ControlType in the parameters.