Multiple Forms in C# [SOLVED]
Multiple Forms in C# [SOLVED]
So i'm working in Windows Forms C# and in a program i'm making there is multiple forms. How would i get it so when i press a button, one form hides and another shows? So there is only 1 form showing at a time. Thanks in advanced! 
Last edited by mattykins on Sat Mar 10, 2012 5:34 am, edited 1 time in total.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Multiple Forms in C#
In C#, forms are handled just as any other object is. You first instantiate a new form, and then call the form.show() method to show it in a non-modal way, or form.showDialog to show it in a modal fashion. You can then call form.hide() on the old form to hide it. Or you can use form.close() to actually remove it from memory. Here is the MSDN entry for the Form class, which has a full listing of the properties and methods you can use in your applications on the Form class.
The indelible lord of tl;dr
Re: Multiple Forms in C#
I had tried that, when I click the start button it runs this code
However it still doesn't hide the Titlescreen form.
Code: Select all
formCharCre f = new formCharCre();
f.Show();
Titlescreen t = new Titlescreen();
t.Hide();
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Multiple Forms in C#
Because you just created a new TitleScreen and hid it without it ever being shown. Instead, inside the TitleScreen class, try:
Code: Select all
this.hide();The indelible lord of tl;dr
Re: Multiple Forms in C#
Thanks, worked great 
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm