|
-
October 23rd, 2011, 03:48 PM
#1
how to override close (X) button in a Windows Form
Hi all,
I was just wondering if there is a way to determine whether a button has been clicked within a closingform event or within another button_click event? For example, I have an app that has one form with three buttons and a propertygrid, one button is called 'Load', it decrypts and then loads data from a xml file which then populates the propertygrid and the other button called 'Save', saves the changes a user makes to the grid and encrypts the xml file, lastly i have a close button. My problem is this, if a user loads the xml (which gets decrypted) but then decides to close the application before clicking the save button (which encypts the xml) the xml file will be left decrypted.
If the user presses the (x) button or the close button to close the application, is there a way within those events i can say if load button_click has been clicked - encrypt file and then close, else just close?
private void LicenseFile_FormClosing(object sender, FormClosingEventArgs e)
{
pseudo code
if BtnLoad_click is pressed
Encrypt xml file
close app
else
close app
}
I would be grateful if someone could help me, thanks in advance.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|