I’m making an application in C# using windows forms, I want to completely swap out all the content in a windows form and replace it with something else. Is there any convenient way to do this?
Example: I have a menu, when I click “start” I want the menu to disappear and the game to start. I’m not using XNA or anything like that which is kind of the point of this whole project.
Use one
Panelfor each unique content set you want to switch. Hide all of the panels, except the initial one. Create a variableactivePanel. SetactivePanelto current shown panel (i.e. initial one).When you need to switch, do the following:
Another approach is to dynamically remove and add Controls to the form, but this way you’ll have to write a lot more code, hovewer, your application memory footprint should be lesser.