Solved

C# - Using the Same Window

Posted on 2004-09-12
8
247 Views
Last Modified: 2010-04-15
I'm working on a small C# application.  I've been writing code in C and Java for several years now, but this is my first experience with C# and Windows Forms, so please excuse me if the question has a simple answer.  I'm sure it's in the MSDN library, but I don't have a copy installed and wasn't able to find what I was looking for online.

I have a form that has several different buttons.  When the button is clicked, I want what's on the form to change.  I basically am going to have a whole new set of options and form fields, so all the existing fields need to disappear.  I know I could do this by just opening a new window, but I want everything to take place within the same form the user is looking at.  Thanks in advance for any help.  
0
Comment
Question by:DragXSlay
8 Comments
 
LVL 3

Expert Comment

by:gillgates
ID: 12040404
Well you could use a tabcontrol and just switch between tabs when buttons are clicked.  Otherwise you have to do object.visible = false; for all of your objects...
0
 
LVL 2

Author Comment

by:DragXSlay
ID: 12040864
Is it possible to hide the tabs in a tab control so that the user doesn't see them and therefore doesn't know what's really happening?  Are there any good docs that you can recommend on the control?
0
 
LVL 22

Expert Comment

by:cookre
ID: 12041117
You know, closing one form and bringing up another would be so much easier, and probably faster than re-doing all the controls.  Not to far mention easier to maintain.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 20

Accepted Solution

by:
TheAvenger earned 250 total points
ID: 12041745
Create two panels and put the two different sets of controls on them. On startup show one of the panels. When the button is clicked, change the panels: make the first one invisible and the second one visible.
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 12041749
Forgot to mention: put the controls that have to be visible at start up on the first panel, those that have to be shown afterwards on the second. Thus you have to hide/show only one control (the panel) instead of all controls.
0
 

Expert Comment

by:faiqq
ID: 12042046
You can use the groupBox component in which you can drag drop components you want. Thus by creating such broupBoxes, you can actually make frames which you can show/hide by the functions BringtoFront()/SendtoBack. A proper usage will give best results and you wont need to open a new form which is not as efficient as this method is; also these will be hidden from the user.
Faiqq
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 12042061
Group boxes have borders, which is probably not wanted, so panels are better. The rest is the same as my solution
0
 
LVL 2

Author Comment

by:DragXSlay
ID: 12049774
TheAvenger,

Thanks for the tip!  It worked perfectly.
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question