我有3张表格。从Form1我用一个按钮打开Form3和Form4。但是,当我按下Form4上的按钮时,我想要关闭Form4和Form3。(不要担心Form2)
Form1中:
private void button1_Click(object sender, EventArgs e)
{
Form3 frm3 = new Form3();
frm3.Show();
Form4 frm4 = new Form4();
frm4.Show();
}
表格4:
private void button12_Click(object sender, EventArgs e){
this.Close();
//Plus close Form3
答案 0 :(得分:0)
Form1中:
private void button1_Click(object sender, EventArgs e) {
Form3 frm3 = new Form3();
frm3.Show();
Form4 frm4 = new Form4(frm3);
frm4.Show();
}
Form4:
Form3 mFrm3Ref;
public Form4(Form3 frm){
mFrm3Ref = frm;
//and other initializing stuff
}
private void button12_Click(object sender, EventArgs e){
mFrm3Ref.Close() ;
this.Close();
}