private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
if (x)
{
return;
}
else
{
if (MessageBox.Show("是否关闭?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
{
e.Cancel = true;
}
}
}
form1里
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (MessageBox.Show("是否退出?", "提示!", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
{
e.Cancel = true;
}
}
private void btnExit_Click_1(object sender, EventArgs e)
{
this.Close();
}