Open Form2 from Form1, close Form1 from Form2

后端 未结 8 686
陌清茗
陌清茗 2020-12-03 13:06

Now, I have two forms, called form1 and form2, in the form1 there\'s a button, when I click it, then open the form2

Question: in the form2, I want to create a button

相关标签:
8条回答
  • 2020-12-03 13:54

    on the form2.buttonclick put

    this.close();
    

    form1 should have object of form2.

    you need to subscribe Closing event of form2.

    and in closing method put

    this.close();
    
    0 讨论(0)
  • 2020-12-03 13:55
    //program to form1 to form2
    private void button1_Click(object sender, EventArgs e)
    {
        //MessageBox.Show("Welcome Admin");
        Form2 frm = new Form2();
        frm.Show();
        this.Hide();          
    }
    
    0 讨论(0)
提交回复
热议问题