Winforms - how to show/hide elements in designer?










24















I am trying to make a multiple page application using winforms. I decied to use multiple Panels - each panel represents different page, so I can switch between them when I need to display different content.



My problem is about stacking panels in designer view. When I have 2+ full screen panels, they all stack on each other and I can't see the one that I created earlier. Is there any solution to this ? Changing visibility does not affect designers view. Think of it as a photoshop-like option to show/hide layers. I'm using Visual C# 2010 Express.










share|improve this question



















  • 1





    If you want to select the other Panel, you can just select it from the drop down. Another solution would be to make them smaller or move them somewhere and programatically adjust their size and location as needed or consider using TabControl control.

    – Lukasz M
    Apr 3 '12 at 17:57
















24















I am trying to make a multiple page application using winforms. I decied to use multiple Panels - each panel represents different page, so I can switch between them when I need to display different content.



My problem is about stacking panels in designer view. When I have 2+ full screen panels, they all stack on each other and I can't see the one that I created earlier. Is there any solution to this ? Changing visibility does not affect designers view. Think of it as a photoshop-like option to show/hide layers. I'm using Visual C# 2010 Express.










share|improve this question



















  • 1





    If you want to select the other Panel, you can just select it from the drop down. Another solution would be to make them smaller or move them somewhere and programatically adjust their size and location as needed or consider using TabControl control.

    – Lukasz M
    Apr 3 '12 at 17:57














24












24








24


6






I am trying to make a multiple page application using winforms. I decied to use multiple Panels - each panel represents different page, so I can switch between them when I need to display different content.



My problem is about stacking panels in designer view. When I have 2+ full screen panels, they all stack on each other and I can't see the one that I created earlier. Is there any solution to this ? Changing visibility does not affect designers view. Think of it as a photoshop-like option to show/hide layers. I'm using Visual C# 2010 Express.










share|improve this question
















I am trying to make a multiple page application using winforms. I decied to use multiple Panels - each panel represents different page, so I can switch between them when I need to display different content.



My problem is about stacking panels in designer view. When I have 2+ full screen panels, they all stack on each other and I can't see the one that I created earlier. Is there any solution to this ? Changing visibility does not affect designers view. Think of it as a photoshop-like option to show/hide layers. I'm using Visual C# 2010 Express.







winforms visual-studio visual-studio-2010






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 14 '18 at 11:34









Stephen Kennedy

7,219135067




7,219135067










asked Apr 3 '12 at 17:52









Kamil N.Kamil N.

1791210




1791210







  • 1





    If you want to select the other Panel, you can just select it from the drop down. Another solution would be to make them smaller or move them somewhere and programatically adjust their size and location as needed or consider using TabControl control.

    – Lukasz M
    Apr 3 '12 at 17:57













  • 1





    If you want to select the other Panel, you can just select it from the drop down. Another solution would be to make them smaller or move them somewhere and programatically adjust their size and location as needed or consider using TabControl control.

    – Lukasz M
    Apr 3 '12 at 17:57








1




1





If you want to select the other Panel, you can just select it from the drop down. Another solution would be to make them smaller or move them somewhere and programatically adjust their size and location as needed or consider using TabControl control.

– Lukasz M
Apr 3 '12 at 17:57






If you want to select the other Panel, you can just select it from the drop down. Another solution would be to make them smaller or move them somewhere and programatically adjust their size and location as needed or consider using TabControl control.

– Lukasz M
Apr 3 '12 at 17:57













7 Answers
7






active

oldest

votes


















27














Several options here:



  1. Use the Document Outline view (View --> Other Windows --> Document Outline) to select the panel you care about. You can right-click on it and choose Bring to Front to put it in front of everything else.

  2. Though it's probably not relevant to what you're doing, you might consider using a TabControl, which you can mess with visually at design time. This is only a reasonable solution if you want your users to be able to manually change which panel they're viewing.

  3. Consider moving your panels into custom UserControl classes and work on them separately. If the content and logic of these panels is reasonably self-contained then you may want to do this anyway just to better restructure your code.


Addendum: You can also use a hack that makes a TabControl's tabs invisible to the user. Put a TabControl on your form, and at run-time set the ItemSize height to 1. This makes it (almost) impossible for the user to change the tabs on their own, but still allows you to change the visible tab in the designer.



myTabControl.ItemSize = new Size(myTabControl.ItemSize.Width, 1);


Note that I called this a hack for a reason: TabControls were not meant to be used this way. It's something that appears to work, but like all hacks it may break at any time so you should only do it as a last resort (and don't blame me if it causes headaches later on...). In short, I do not recommend this hack, I only offer it as a possibility.






share|improve this answer

























  • I decided to use bring to front/send to back option because this is the easiest solution for now and It does not involve changing my applications structure (tab control). Unfortunately I couldn't find the View->other windows->document outline so I have to use send to back on all panels until I reach the one I'm looking for.

    – Kamil N.
    Apr 3 '12 at 18:50


















4














I use "Bring to front" or "Send to back" under Format > Order to manage this kind of scenario, but you're right, it kind of sucks that visibility is only runtime (AFAIK).



Cheers






share|improve this answer






























    1














    I am not sure about the right way to do this, but what I do myself in this cases is jyst make controls very small and later on program run I change theire sizes and locations on start.






    share|improve this answer






























      0














      One approach that I've used in this situation is to use the Document Explorer window to bring the panel I'm working on to the front.






      share|improve this answer






























        0














        So you want to be able to show/hide your panel in the VS Designer View (not just when the actual executable is running) correct?



        Would something like this help?



        If not, then perhaps you could try creating custom user controls instead of panels which would allow you to set the visibility properties as you like or you could resort to using WPF which provides this type of functionality. Click here for more information.






        share|improve this answer






























          0














          If it's acceptable for you, consider using a TabControl control and put each of the Panel controls in a different tab. You can then hide and show correct page by switching between tabs or programatically removing and adding appropriate tab to the control.



          You can also consider using two different windows with different layouts and showing switching between them.



          If you use more than only a few panels, you can consider putting each of them in a separate control and then just use the controls within the application's form (i.e. add them programatically when needed). This way, you can design each of the controls (so each of the Panel's contents) separately, whitout other Panels visible.



          Each of those suggestions would make some UI pieces more separated, which can be desired if each of the layouts you've got is associated with a separate piece of the application. Using those suggestions can also make it much easier to use the deisgner to manage.






          share|improve this answer
































            0














            Try this.richTextBox1.Visible = false; in your Form1.cs (assuming you are trying to hide a rich text box with the default name "richTextBox1")






            share|improve this answer






















              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f9998672%2fwinforms-how-to-show-hide-elements-in-designer%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              7 Answers
              7






              active

              oldest

              votes








              7 Answers
              7






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              27














              Several options here:



              1. Use the Document Outline view (View --> Other Windows --> Document Outline) to select the panel you care about. You can right-click on it and choose Bring to Front to put it in front of everything else.

              2. Though it's probably not relevant to what you're doing, you might consider using a TabControl, which you can mess with visually at design time. This is only a reasonable solution if you want your users to be able to manually change which panel they're viewing.

              3. Consider moving your panels into custom UserControl classes and work on them separately. If the content and logic of these panels is reasonably self-contained then you may want to do this anyway just to better restructure your code.


              Addendum: You can also use a hack that makes a TabControl's tabs invisible to the user. Put a TabControl on your form, and at run-time set the ItemSize height to 1. This makes it (almost) impossible for the user to change the tabs on their own, but still allows you to change the visible tab in the designer.



              myTabControl.ItemSize = new Size(myTabControl.ItemSize.Width, 1);


              Note that I called this a hack for a reason: TabControls were not meant to be used this way. It's something that appears to work, but like all hacks it may break at any time so you should only do it as a last resort (and don't blame me if it causes headaches later on...). In short, I do not recommend this hack, I only offer it as a possibility.






              share|improve this answer

























              • I decided to use bring to front/send to back option because this is the easiest solution for now and It does not involve changing my applications structure (tab control). Unfortunately I couldn't find the View->other windows->document outline so I have to use send to back on all panels until I reach the one I'm looking for.

                – Kamil N.
                Apr 3 '12 at 18:50















              27














              Several options here:



              1. Use the Document Outline view (View --> Other Windows --> Document Outline) to select the panel you care about. You can right-click on it and choose Bring to Front to put it in front of everything else.

              2. Though it's probably not relevant to what you're doing, you might consider using a TabControl, which you can mess with visually at design time. This is only a reasonable solution if you want your users to be able to manually change which panel they're viewing.

              3. Consider moving your panels into custom UserControl classes and work on them separately. If the content and logic of these panels is reasonably self-contained then you may want to do this anyway just to better restructure your code.


              Addendum: You can also use a hack that makes a TabControl's tabs invisible to the user. Put a TabControl on your form, and at run-time set the ItemSize height to 1. This makes it (almost) impossible for the user to change the tabs on their own, but still allows you to change the visible tab in the designer.



              myTabControl.ItemSize = new Size(myTabControl.ItemSize.Width, 1);


              Note that I called this a hack for a reason: TabControls were not meant to be used this way. It's something that appears to work, but like all hacks it may break at any time so you should only do it as a last resort (and don't blame me if it causes headaches later on...). In short, I do not recommend this hack, I only offer it as a possibility.






              share|improve this answer

























              • I decided to use bring to front/send to back option because this is the easiest solution for now and It does not involve changing my applications structure (tab control). Unfortunately I couldn't find the View->other windows->document outline so I have to use send to back on all panels until I reach the one I'm looking for.

                – Kamil N.
                Apr 3 '12 at 18:50













              27












              27








              27







              Several options here:



              1. Use the Document Outline view (View --> Other Windows --> Document Outline) to select the panel you care about. You can right-click on it and choose Bring to Front to put it in front of everything else.

              2. Though it's probably not relevant to what you're doing, you might consider using a TabControl, which you can mess with visually at design time. This is only a reasonable solution if you want your users to be able to manually change which panel they're viewing.

              3. Consider moving your panels into custom UserControl classes and work on them separately. If the content and logic of these panels is reasonably self-contained then you may want to do this anyway just to better restructure your code.


              Addendum: You can also use a hack that makes a TabControl's tabs invisible to the user. Put a TabControl on your form, and at run-time set the ItemSize height to 1. This makes it (almost) impossible for the user to change the tabs on their own, but still allows you to change the visible tab in the designer.



              myTabControl.ItemSize = new Size(myTabControl.ItemSize.Width, 1);


              Note that I called this a hack for a reason: TabControls were not meant to be used this way. It's something that appears to work, but like all hacks it may break at any time so you should only do it as a last resort (and don't blame me if it causes headaches later on...). In short, I do not recommend this hack, I only offer it as a possibility.






              share|improve this answer















              Several options here:



              1. Use the Document Outline view (View --> Other Windows --> Document Outline) to select the panel you care about. You can right-click on it and choose Bring to Front to put it in front of everything else.

              2. Though it's probably not relevant to what you're doing, you might consider using a TabControl, which you can mess with visually at design time. This is only a reasonable solution if you want your users to be able to manually change which panel they're viewing.

              3. Consider moving your panels into custom UserControl classes and work on them separately. If the content and logic of these panels is reasonably self-contained then you may want to do this anyway just to better restructure your code.


              Addendum: You can also use a hack that makes a TabControl's tabs invisible to the user. Put a TabControl on your form, and at run-time set the ItemSize height to 1. This makes it (almost) impossible for the user to change the tabs on their own, but still allows you to change the visible tab in the designer.



              myTabControl.ItemSize = new Size(myTabControl.ItemSize.Width, 1);


              Note that I called this a hack for a reason: TabControls were not meant to be used this way. It's something that appears to work, but like all hacks it may break at any time so you should only do it as a last resort (and don't blame me if it causes headaches later on...). In short, I do not recommend this hack, I only offer it as a possibility.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Apr 3 '12 at 18:16

























              answered Apr 3 '12 at 18:09









              ean5533ean5533

              7,31633260




              7,31633260












              • I decided to use bring to front/send to back option because this is the easiest solution for now and It does not involve changing my applications structure (tab control). Unfortunately I couldn't find the View->other windows->document outline so I have to use send to back on all panels until I reach the one I'm looking for.

                – Kamil N.
                Apr 3 '12 at 18:50

















              • I decided to use bring to front/send to back option because this is the easiest solution for now and It does not involve changing my applications structure (tab control). Unfortunately I couldn't find the View->other windows->document outline so I have to use send to back on all panels until I reach the one I'm looking for.

                – Kamil N.
                Apr 3 '12 at 18:50
















              I decided to use bring to front/send to back option because this is the easiest solution for now and It does not involve changing my applications structure (tab control). Unfortunately I couldn't find the View->other windows->document outline so I have to use send to back on all panels until I reach the one I'm looking for.

              – Kamil N.
              Apr 3 '12 at 18:50





              I decided to use bring to front/send to back option because this is the easiest solution for now and It does not involve changing my applications structure (tab control). Unfortunately I couldn't find the View->other windows->document outline so I have to use send to back on all panels until I reach the one I'm looking for.

              – Kamil N.
              Apr 3 '12 at 18:50













              4














              I use "Bring to front" or "Send to back" under Format > Order to manage this kind of scenario, but you're right, it kind of sucks that visibility is only runtime (AFAIK).



              Cheers






              share|improve this answer



























                4














                I use "Bring to front" or "Send to back" under Format > Order to manage this kind of scenario, but you're right, it kind of sucks that visibility is only runtime (AFAIK).



                Cheers






                share|improve this answer

























                  4












                  4








                  4







                  I use "Bring to front" or "Send to back" under Format > Order to manage this kind of scenario, but you're right, it kind of sucks that visibility is only runtime (AFAIK).



                  Cheers






                  share|improve this answer













                  I use "Bring to front" or "Send to back" under Format > Order to manage this kind of scenario, but you're right, it kind of sucks that visibility is only runtime (AFAIK).



                  Cheers







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Apr 3 '12 at 18:01









                  Luc MorinLuc Morin

                  4,7221431




                  4,7221431





















                      1














                      I am not sure about the right way to do this, but what I do myself in this cases is jyst make controls very small and later on program run I change theire sizes and locations on start.






                      share|improve this answer



























                        1














                        I am not sure about the right way to do this, but what I do myself in this cases is jyst make controls very small and later on program run I change theire sizes and locations on start.






                        share|improve this answer

























                          1












                          1








                          1







                          I am not sure about the right way to do this, but what I do myself in this cases is jyst make controls very small and later on program run I change theire sizes and locations on start.






                          share|improve this answer













                          I am not sure about the right way to do this, but what I do myself in this cases is jyst make controls very small and later on program run I change theire sizes and locations on start.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Apr 3 '12 at 17:57









                          Saeid YazdaniSaeid Yazdani

                          6,33339135244




                          6,33339135244





















                              0














                              One approach that I've used in this situation is to use the Document Explorer window to bring the panel I'm working on to the front.






                              share|improve this answer



























                                0














                                One approach that I've used in this situation is to use the Document Explorer window to bring the panel I'm working on to the front.






                                share|improve this answer

























                                  0












                                  0








                                  0







                                  One approach that I've used in this situation is to use the Document Explorer window to bring the panel I'm working on to the front.






                                  share|improve this answer













                                  One approach that I've used in this situation is to use the Document Explorer window to bring the panel I'm working on to the front.







                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered Apr 3 '12 at 17:57









                                  RQDQRQDQ

                                  12.8k12344




                                  12.8k12344





















                                      0














                                      So you want to be able to show/hide your panel in the VS Designer View (not just when the actual executable is running) correct?



                                      Would something like this help?



                                      If not, then perhaps you could try creating custom user controls instead of panels which would allow you to set the visibility properties as you like or you could resort to using WPF which provides this type of functionality. Click here for more information.






                                      share|improve this answer



























                                        0














                                        So you want to be able to show/hide your panel in the VS Designer View (not just when the actual executable is running) correct?



                                        Would something like this help?



                                        If not, then perhaps you could try creating custom user controls instead of panels which would allow you to set the visibility properties as you like or you could resort to using WPF which provides this type of functionality. Click here for more information.






                                        share|improve this answer

























                                          0












                                          0








                                          0







                                          So you want to be able to show/hide your panel in the VS Designer View (not just when the actual executable is running) correct?



                                          Would something like this help?



                                          If not, then perhaps you could try creating custom user controls instead of panels which would allow you to set the visibility properties as you like or you could resort to using WPF which provides this type of functionality. Click here for more information.






                                          share|improve this answer













                                          So you want to be able to show/hide your panel in the VS Designer View (not just when the actual executable is running) correct?



                                          Would something like this help?



                                          If not, then perhaps you could try creating custom user controls instead of panels which would allow you to set the visibility properties as you like or you could resort to using WPF which provides this type of functionality. Click here for more information.







                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered Apr 3 '12 at 18:14









                                          Ami SchreiberAmi Schreiber

                                          1662419




                                          1662419





















                                              0














                                              If it's acceptable for you, consider using a TabControl control and put each of the Panel controls in a different tab. You can then hide and show correct page by switching between tabs or programatically removing and adding appropriate tab to the control.



                                              You can also consider using two different windows with different layouts and showing switching between them.



                                              If you use more than only a few panels, you can consider putting each of them in a separate control and then just use the controls within the application's form (i.e. add them programatically when needed). This way, you can design each of the controls (so each of the Panel's contents) separately, whitout other Panels visible.



                                              Each of those suggestions would make some UI pieces more separated, which can be desired if each of the layouts you've got is associated with a separate piece of the application. Using those suggestions can also make it much easier to use the deisgner to manage.






                                              share|improve this answer





























                                                0














                                                If it's acceptable for you, consider using a TabControl control and put each of the Panel controls in a different tab. You can then hide and show correct page by switching between tabs or programatically removing and adding appropriate tab to the control.



                                                You can also consider using two different windows with different layouts and showing switching between them.



                                                If you use more than only a few panels, you can consider putting each of them in a separate control and then just use the controls within the application's form (i.e. add them programatically when needed). This way, you can design each of the controls (so each of the Panel's contents) separately, whitout other Panels visible.



                                                Each of those suggestions would make some UI pieces more separated, which can be desired if each of the layouts you've got is associated with a separate piece of the application. Using those suggestions can also make it much easier to use the deisgner to manage.






                                                share|improve this answer



























                                                  0












                                                  0








                                                  0







                                                  If it's acceptable for you, consider using a TabControl control and put each of the Panel controls in a different tab. You can then hide and show correct page by switching between tabs or programatically removing and adding appropriate tab to the control.



                                                  You can also consider using two different windows with different layouts and showing switching between them.



                                                  If you use more than only a few panels, you can consider putting each of them in a separate control and then just use the controls within the application's form (i.e. add them programatically when needed). This way, you can design each of the controls (so each of the Panel's contents) separately, whitout other Panels visible.



                                                  Each of those suggestions would make some UI pieces more separated, which can be desired if each of the layouts you've got is associated with a separate piece of the application. Using those suggestions can also make it much easier to use the deisgner to manage.






                                                  share|improve this answer















                                                  If it's acceptable for you, consider using a TabControl control and put each of the Panel controls in a different tab. You can then hide and show correct page by switching between tabs or programatically removing and adding appropriate tab to the control.



                                                  You can also consider using two different windows with different layouts and showing switching between them.



                                                  If you use more than only a few panels, you can consider putting each of them in a separate control and then just use the controls within the application's form (i.e. add them programatically when needed). This way, you can design each of the controls (so each of the Panel's contents) separately, whitout other Panels visible.



                                                  Each of those suggestions would make some UI pieces more separated, which can be desired if each of the layouts you've got is associated with a separate piece of the application. Using those suggestions can also make it much easier to use the deisgner to manage.







                                                  share|improve this answer














                                                  share|improve this answer



                                                  share|improve this answer








                                                  edited Apr 3 '12 at 18:14

























                                                  answered Apr 3 '12 at 18:05









                                                  Lukasz MLukasz M

                                                  4,98011628




                                                  4,98011628





















                                                      0














                                                      Try this.richTextBox1.Visible = false; in your Form1.cs (assuming you are trying to hide a rich text box with the default name "richTextBox1")






                                                      share|improve this answer



























                                                        0














                                                        Try this.richTextBox1.Visible = false; in your Form1.cs (assuming you are trying to hide a rich text box with the default name "richTextBox1")






                                                        share|improve this answer

























                                                          0












                                                          0








                                                          0







                                                          Try this.richTextBox1.Visible = false; in your Form1.cs (assuming you are trying to hide a rich text box with the default name "richTextBox1")






                                                          share|improve this answer













                                                          Try this.richTextBox1.Visible = false; in your Form1.cs (assuming you are trying to hide a rich text box with the default name "richTextBox1")







                                                          share|improve this answer












                                                          share|improve this answer



                                                          share|improve this answer










                                                          answered Nov 13 '18 at 22:10









                                                          WilliamWilliam

                                                          1746




                                                          1746



























                                                              draft saved

                                                              draft discarded
















































                                                              Thanks for contributing an answer to Stack Overflow!


                                                              • Please be sure to answer the question. Provide details and share your research!

                                                              But avoid


                                                              • Asking for help, clarification, or responding to other answers.

                                                              • Making statements based on opinion; back them up with references or personal experience.

                                                              To learn more, see our tips on writing great answers.




                                                              draft saved


                                                              draft discarded














                                                              StackExchange.ready(
                                                              function ()
                                                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f9998672%2fwinforms-how-to-show-hide-elements-in-designer%23new-answer', 'question_page');

                                                              );

                                                              Post as a guest















                                                              Required, but never shown





















































                                                              Required, but never shown














                                                              Required, but never shown












                                                              Required, but never shown







                                                              Required, but never shown

































                                                              Required, but never shown














                                                              Required, but never shown












                                                              Required, but never shown







                                                              Required, but never shown







                                                              這個網誌中的熱門文章

                                                              How to read a connectionString WITH PROVIDER in .NET Core?

                                                              In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

                                                              Museum of Modern and Contemporary Art of Trento and Rovereto