By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,996 Members | 1,179 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,996 IT Pros & Developers. It's quick & easy.

How to show some message when User click on X button of form in vb.net

P: 13
Hi,
Please help
I what show some message when user click on X button of form which is at upper side corner of the form in vb.net
Nov 20 '07 #1
Share this Question
Share on Google+
1 Reply


dip_developer
Expert 100+
P: 648
Hi,
Please help
I what show some message when user click on X button of form which is at upper side corner of the form in vb.net
grab the form_closing eventhandler.......try the following code...

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
  3. If MessageBox.Show("Do you want to save changes to your text?", "My Application", MessageBoxButtons.YesNo) = DialogResult.Yes Then
  4.  
  5. ' Cancel the Closing event from closing the form. 
  6. e.Cancel = True
  7. Else
  8. e.Cancel = False
  9. ' Call method to save file...
  10. End If 
  11. End Sub
  12.  
Nov 20 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.