I've seen this question asked many times, but the answer is always something about using panels and nothing more. Let's say I have an application that has 25 different "pages" of content. I can manage all of these with panels of course, but what's the best way to go about designing this way? You can't exactly fit 25 panels worth of content into the Visual Studio designer. Is there some feature that I'm blindly unaware of that would allow for easier management of dozens of panels?
1 Answers
You missed the actual advice given 90% of the time: Use UserControls
!
They are like Forms but you can add them to a Form. See here for a discussion and here and here for more about why and how to do that and here for a walk-through of accessor routines...
Or see here and here for an alternative. It uses a TabControl
but only for the developer; at runtime the TabControl
is hidden and the selected content container (a Panel probably) is moved from its TabPage to another container on the foom or to the form directly.
UserControls
pose a challenge wrt accessablilty as their member controls by default are private
. But you can change the modifiers
to public
in the designer or by writing accessor functions. The Tab-trick avoids that by having everything in the the form class; this is simpler but less structured and not well-suited for re-use..
-
That's genius! Not sure how I missed this. This will make things so much easier moving forward. Thanks so much! – Branden Jun 12 '16 at 04:00
-
Note the [added 'walk-trough' link](http://stackoverflow.com/questions/34965343/c-sharp-winform-custom-grid-layout/34968221#34968221). This is the one I really had wanted to add but couldn't find last night.. – TaW Jun 12 '16 at 07:01