废话不多说了,直接给大家贴代码了,代码中有注释,大家多看看。 private void Form1_FormClosing(object sender, FormClosingEventArgs e) { DialogResult re = MessageBox.Show(确定离开吗,询问,MessageBoxButtons.YesNo,MessageBoxIcon.Question); if(re==DialogResult.No) { e.Cancel = true; } } private void button1_Click(object sender, EventArgs