Click here to Skip to main content
15,883,831 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I hav deveploed a C# project.I hav mutilple form in it. I want to close or hide the first form specified in Program.cs. I hav tried the code given here

private void btnClose_Click(object sender, EventArgs e)
{
Form frmSecond = new frmSecond();
frmSecond.Show();
frmSecond.Activate();
this.Close();
}

It doesnt work it closes Form1 the entres into Program.cs and again opens Form1. Is there any way to just hide or close it??


Thanks!!!
Posted

You call the code to show frmSecond from Program.Main(). Alternatively, you could call Hide() on the first form. However, you will need to signal that form to close at some point or else your program will never terminate.
 
Share this answer
 
v2
 
Share this answer
 
v2
I hav tried the code suggested by u Mr.Abhinav S.Sorry but this code doesnt work it opens again the first form.
 
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