net windows form application. I have a combo box and a text box and a close window button. Now If I make any change in the combo box or textbox and click on the close window button, it should prompt the user to save the modifications.. If no modification are made ( The user will just run the application, doesnt make any modification) then it should not prompt the user. It should close directly.. How can I do this?
An easy way to do it is by adding a dirty
member to the form, which I set to true
whenever anything changes and then check it whenever the form is closing .
Override the OnClosing method of your form (or attach to the Closing event). In the handler check for modifications and display a message box to the user. If you do not want the form to close just set the e.Cancel property to false before returning.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With