Stop form from closing

  • Thread starter Thread starter John S
  • Start date Start date
J

John S

When the user clicks the "X" in the upper right-hand corner of a form, how
can I stop the form from closing?
 
John S said:
When the user clicks the "X" in the upper right-hand
corner of a form, how can I stop the form from closing?

Handle the Form Closing event and set e.Cancel = true.

Be aware that overriding what the user wants to do can be rather
annoying.

P.
 
John said:
When the user clicks the "X" in the upper right-hand corner of a
form, how can I stop the form from closing?

You have to handle the Closing event and take appropriate action (ie set the
Cancel property of the event's arg to true). Have a look at the doc for this
event for all implications of doing that. This is very simple to do but this
may lead to other problems if you are not careful:
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html
/frlrfSystemWindowsFormsFormClassClosingTopic.asp>
 
Hi,

Handle the form's Closing event and set the event argument's Cancel property
to true.

When the user clicks the "X" in the upper right-hand corner of a form, how
can I stop the form from closing?
 
Patient: "Doc, how do I stop my arm from hurting when I raise it above my head"
Doc: "Don't raise it above your head"
 
Hi,

LOL

also you can handle the Closing event and set the Cancel property to true

very easy :) you still get the X as the user expect but you have control
over the closing

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top