In my code i from form1 launch form2 using .Show()
.
Form2 f2 = new Form2();
f2.show();
block form1
until form2
close and when form2
closed continue my code.
.Show()
将显示您正在显示的新表单,但它将使您能够返回并使用主表单中的控件, .ShowDialog()
不允许您访问主表单,除非将其关闭。
f2.ShowDialog();
Try using
Form2 f2 = new Form2();
f2.showDialog();
I tested that ways and don't worked but only below code worked:
private void button1_Click_1(object sender, EventArgs e)
{
Form2 frm = new Form2();
this.Enabled = false;
frm.Show();
frm.FormClosing += new FormClosingEventHandler(frm_FormClosing);
frm.Show();
}
private void frm_FormClosing(object sender, FormClosingEventArgs e)
{
this.Enabled = true;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.