Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道是否有任何方法可以设置 Windows 窗体,以便当用户单击红色 X 按钮时,它不会关闭窗体,而是显示一个消息框,内容为“您确定要退出吗? " 是否有 Windows 形式的 certian 事件或我需要做的其他一些工作?
FormClosing += new FormClosingEventHandler(Form1_FormClosing);
和:
void Form1_FormClosing(object sender, FormClosingEventArgs e) { if (MessageBox.Show("...","...", MessageBoxButtons.OKCancel) == DialogResult.OK) e.Cancel = true; }