What is the best way to disable Alt + F4 in a c# win form to prevent the user from closing the form?
我使用表单作为弹出对话框来显示进度条,但我不希望用户能够关闭它。
这可以完成工作:
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
}
编辑:回应 pix0rs 的担忧 - 是的,你是对的,你将无法以编程方式关闭应用程序。但是,您可以在关闭表单之前简单地删除 form_looking 事件的事件处理程序:
this.FormClosing -= new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
this.Close();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)