I'm new to .NET. I have a Java SWING background. Thus far I'm finding .NET and Visual Studio very easy to work with. However, I have one point of confusion that I just can't seem to get past. I'm designing a small application that has several "screens" of information that will be displayed (ex. one for searching and displaying search results, another for viewing summary information, and another for viewing detail information, etc.). Under Java SWING, I would create a JFrame that contains a menu, which would be my main application window. I would then create several JPanels that I would swap in and out of the main window (JFrame)depending on what "screen" (JPanel) I want to show at the time (based on menu selection or other user interaction). I'm trying to replicate this pattern in .NET using C# and Visual Studio and I'm a little stumped on the approach. Thus far I have created a form for each one of my "screens", replicating the menu on each one. I realize that I should probably create base class form that contains the menu, and then each of my formsrepresentingmy"screens" can inherit from the base class. I understand the basics of .NETforms but I'm wondering if I should create a single form and swap out panels representing my "screens". If this is the answer, how do I do this in Visual Designer, since all panels would reside in the sameForm, which would make it difficult to view in Designer?For SWING, each JPanel acts as its own UI component in JBuilder so it makes it nice to lay out my different "screens" of data, and then I just swap out the panels within the main JFrame (similiar to a .NET Form) during runtime. I'm having trouble making the paradigm shift in .NET. Any help or guidance would be appreciated. The users' don't want multiple "Windows" open/visible at any one time on the desktop. Again, I understand the basics, my question is one more of architecture. Thanks very much! | | Lisa_newbie Monday, August 17, 2009 3:47 PM | You can accomplish something similar to your SWING JPanel by building each "screen" as a .NET UserControl. UserControls could be swapped in and out of a single window, and act more like JPanel does in swing. That being said, it's more common for applications on Windows to just use separate forms for separate tasks. It's just as easy (or easier) to hide/close a form and replace it with a new form as it is to swap out content, and will have a very similar effect, although it gives you more control. (In this case, you can handle the user closing your form in each "screen" differently - sometimes, you may want to prevent this or prompt the user, other times, you may want to close the application, etc.) Think about how you want the user to interact with your application, and design around that.
Reed Copsey, Jr. - http://reedcopsey.com- Marked As Answer byAland LiMSFT, ModeratorWednesday, August 19, 2009 12:30 PM
-
| | Reed Copsey, Jr. Monday, August 17, 2009 6:06 PM | Use a UserControl, it sounds like a direct match for a JPanel. Swap them in and out of your main form (JFrame). The details are a wee bit tricky, you do have to manually dispose a user control if you swap it out. Check this thread for a code sample.
Hans Passant. - Marked As Answer byAland LiMSFT, ModeratorWednesday, August 19, 2009 12:30 PM
-
| | nobugz Tuesday, August 18, 2009 1:45 AM | You can accomplish something similar to your SWING JPanel by building each "screen" as a .NET UserControl. UserControls could be swapped in and out of a single window, and act more like JPanel does in swing. That being said, it's more common for applications on Windows to just use separate forms for separate tasks. It's just as easy (or easier) to hide/close a form and replace it with a new form as it is to swap out content, and will have a very similar effect, although it gives you more control. (In this case, you can handle the user closing your form in each "screen" differently - sometimes, you may want to prevent this or prompt the user, other times, you may want to close the application, etc.) Think about how you want the user to interact with your application, and design around that.
Reed Copsey, Jr. - http://reedcopsey.com- Marked As Answer byAland LiMSFT, ModeratorWednesday, August 19, 2009 12:30 PM
-
| | Reed Copsey, Jr. Monday, August 17, 2009 6:06 PM | Use a UserControl, it sounds like a direct match for a JPanel. Swap them in and out of your main form (JFrame). The details are a wee bit tricky, you do have to manually dispose a user control if you swap it out. Check this thread for a code sample.
Hans Passant. - Marked As Answer byAland LiMSFT, ModeratorWednesday, August 19, 2009 12:30 PM
-
| | nobugz Tuesday, August 18, 2009 1:45 AM | Okay, I get what you are saying about having different forms and hiding and showing them but how then do I have the same menu on each form?
Thanks, Lisa | | Lisa_newbie Wednesday, September 30, 2009 8:13 PM |
|