how do i set a form to e.Cancel = True

seanvoth

Well-known member
Joined
Aug 5, 2006
Messages
58
Programming Experience
1-3
i want
e.Cancel =
True
to go on a form so u have to click end and not (X) to close the program
 
That is a bad idea. There's generally no reason that you should not let the user close the form from the Close button on the title bar. If you want to make sure that the user saves their work then you should check for pending changes in the FormClosing event and then prompt the user if there are pending changes. You can then let the user choose to cancel the close then if they want. If there really is a legitimate reason that you don't want the user to use the Close button on the title bar then don't let them press it at all. Generally the only reason to disallow its use is in a dialogue box, in which case you shouldn't need the Maximize or Minimize buttons either, so you can set the form's ControlBox property to False to remove them all. If you do need the Maximize and Minimize buttons then you should use the Windows API to disable the Close button. See the link below for how to do that.

http://www.vbforums.com/showthread.php?t=351533
 
Back
Top