prevent user closing the application

  • Thread starter Thread starter alan
  • Start date Start date
A

alan

Hello,

When the user try the close the application (click the top right side
button "X"), I would like to do a checking first. If the checking return
false, prevent the application terminate. Anyone know how to do it?
Thanks.
 
private void Form1_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
if(some closing condition is not met)
{
e.Cancel = true;
}
}

Beware, this will also prevent windows from being able to close it when
you shut down your computer.
 
Oh! Is there nothing like a VB:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

Where 'UnloadMode' shows how the form is closing?

TIA
Krishnan
Codito Ergo Sum

private void Form1_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
if(some closing condition is not met)
{
e.Cancel = true;
}
}

Beware, this will also prevent windows from being able to close it when
you shut down your computer.
 
Not sure, never used it as an email client, but I use it as a news
reader. It seems to do fine handling tens of thousands of mails in each
group. The line is sort of a default signature and I haven't changed it
yet.
 
Back
Top