PC Review


Reply
Thread Tools Rate Thread

How to Cancel a Cancel Button event

 
 
Eric T.
Guest
Posts: n/a
 
      4th Feb 2009
When the user presses Cancel on my form, I want there to be an opportunity to
cancel the cancel, i.e. "Do you really want to abort the changes you've
made". If the user presses N, I don't want it to exit. If the user presses
Y, I set the DialogResult to Cancel and call this.Close(). I don't do
anything if the user presses N, but the form closes anyways. How do I stop
the form from closing?
Thanks
PS - The cancel button object is registered in the form as the CancelButton.
 
Reply With Quote
 
 
 
 
Eric T.
Guest
Posts: n/a
 
      4th Feb 2009
Doh -- set DialogResult to None...



"Eric T." wrote:

> When the user presses Cancel on my form, I want there to be an opportunity to
> cancel the cancel, i.e. "Do you really want to abort the changes you've
> made". If the user presses N, I don't want it to exit. If the user presses
> Y, I set the DialogResult to Cancel and call this.Close(). I don't do
> anything if the user presses N, but the form closes anyways. How do I stop
> the form from closing?
> Thanks
> PS - The cancel button object is registered in the form as the CancelButton.

 
Reply With Quote
 
miher
Guest
Posts: n/a
 
      4th Feb 2009
Hi,

You can use the Form.FormClosing event, to cancel the close, just set the
FormClosingEventArgs parameters Cancel property to true.

Hope You find this useful.
-Zsolt


"Eric T." <(E-Mail Removed)> az alábbiakat Ã*rta a következÅ‘
üzenetben news:4D94E108-A98E-4AA7-8C2D-(E-Mail Removed)...
> When the user presses Cancel on my form, I want there to be an opportunity
> to
> cancel the cancel, i.e. "Do you really want to abort the changes you've
> made". If the user presses N, I don't want it to exit. If the user
> presses
> Y, I set the DialogResult to Cancel and call this.Close(). I don't do
> anything if the user presses N, but the form closes anyways. How do I
> stop
> the form from closing?
> Thanks
> PS - The cancel button object is registered in the form as the
> CancelButton.


 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      5th Feb 2009
"Eric T." <(E-Mail Removed)> schrieb:
> When the user presses Cancel on my form, I want there to be an opportunity
> to
> cancel the cancel, i.e. "Do you really want to abort the changes you've
> made". If the user presses N, I don't want it to exit. If the user
> presses
> Y, I set the DialogResult to Cancel and call this.Close(). I don't do
> anything if the user presses N, but the form closes anyways. How do I
> stop
> the form from closing?


Just do not assign a 'DialogResult' to the button's 'DialogResult' property
at design time.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CancelEventArgs.Cancel - How Event Raising Code Know if Client Set .Cancel=true Smithers Microsoft C# .NET 3 24th Sep 2007 02:30 AM
Cancel a click event on a button Gallarpri Microsoft C# .NET 3 18th Jan 2007 12:52 PM
Cancel button to cancel the whole macro excelnut1954 Microsoft Excel Programming 5 17th Jan 2006 08:27 PM
Cancel Cllick Event Won't Cancel Mike Boozer Microsoft Access Form Coding 4 28th Apr 2004 02:36 AM
Re: Cancel Event/Button MYuen Microsoft Access Getting Started 0 26th Aug 2003 05:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:41 AM.