C# 当我点击 窗体右上角 “叉”时,如何弹出提示框

2024-12-03 04:09:09
推荐回答(2个)
回答1:

private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
DialogResult result;
result = MessageBox.Show("确定删除", "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
e.Cancel = false;
}
else
{
e.Cancel = true;
}
}

回答2:

close事件
messagebox.show(...)