Reputation: 35
private void btnLogin_Click(object sender, EventArgs e)
{
Form1 frm = new Form1();
frm.Hide();
Here form1 is not hiding and btnLogin is in form2
Upvotes: 3
Views: 2558
Reputation: 2366
Try this:
// Method in Form1
private void button1_Click(object sender, EventArgs e)
{
Form2 mySecondForm = new Form2(this);
mySecondForm.Show();
}
// This is the second form which you opened from your first form..
public partial class Form2 : Form
{
Form someForm;
public Form2(Form parentForm)
{
InitializeComponent();
someForm = parentForm;
}
private void button1_Click(object sender, EventArgs e)
{
someForm.Hide(); // Form1 should hide now
}
}
Hope this helps. Cheers.
Upvotes: 8