Click here to Skip to main content
15,888,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want some changes to be made in the database when the user deliberately closes the win form.

What I have tried:

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
       {
           if(e.CloseReason==CloseReason.UserClosing)
           {
               e.Cancel = true; /* if it is true then it can be seen that the
                                 statements inside the formclosing methods runs
                                  twice(which causes the problem) before going to
                                  formclosed. when i set it to false then the problem
                                  gets resolved and y is that so */
               this.Hide();
               UpdateToken();
           }
       }
Posted
Updated 14-Oct-18 10:33am
Comments

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900