frist way
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
}
{
e.Cancel = true;
}
second way
You can handle "Alt+F4" KeyDown to disable it.
1. set "KeyPreview" of your form to "true"
2. add "KeyDown" handler for your form (or override "OnKeyDown" method)
private void Form1_KeyDown(object sender
, System.Windows.Forms.KeyEventArgs e) {
if( e.Alt && e.KeyCode==Keys.F4 ) {
e.Handled=true;
}
}
1. set "KeyPreview" of your form to "true"
2. add "KeyDown" handler for your form (or override "OnKeyDown" method)
private void Form1_KeyDown(object sender
, System.Windows.Forms.KeyEventArgs e) {
if( e.Alt && e.KeyCode==Keys.F4 ) {
e.Handled=true;
}
}
0 comment:
إرسال تعليق