Click here to Skip to main content
15,921,884 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have one form in c# windows form and there is one button that when we click on it there will be open another form. The problem is how can I hide the first form when other form is open. I dont want to have both forms. So when I click in button open the new form but the old form hide or close...

thnx
Posted

Hi h5h5,

I assume you have two forms- Form1 & Form2 and on Form1 you've a button to show up Form2.

Inside Button_Click event of the button on Form1, write below codes and you're done with what you want.

C#
private void button3_Click(object sender, EventArgs e)
        {
            Form2 frm = new Form2();
            this.Hide();
            frm.Show();
        }



Happy Coding :)
Sunny_K
 
Share this answer
 
when u close first form than if ur application close than you need to set application setting set shutdown mode ->when last form close.
on click of button where u show next form write code like this
SQL
NextForm.Show()
            Close()
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900