PC Review


Reply
Thread Tools Rate Thread

DialogResult and CancelButton

 
 
Lee Moody
Guest
Posts: n/a
 
      24th Mar 2004
If you specify a CancelButton property on a form to a
specific button, but you specify 'None' as DialogResult
for that button, and you show the form using ShowDialog,
pressing ESCape key is causing the DialogResult to fire
and closes the form.

Is this another potential design flaw or is this on
purpose?

-Lee
 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      24th Mar 2004
* "Lee Moody" <(E-Mail Removed)> scripsit:
> If you specify a CancelButton property on a form to a
> specific button, but you specify 'None' as DialogResult
> for that button, and you show the form using ShowDialog,
> pressing ESCape key is causing the DialogResult to fire
> and closes the form.


The button will be fired, but no 'DialogResult' will be set. You can
set the 'DialogResult' in the cancel button's 'Click' event handler.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
 
Reply With Quote
 
Lee Moody
Guest
Posts: n/a
 
      24th Mar 2004
My point is, what you've described is what I would EXPECT
to happen, but that is not happening. The DialogResult IS
being executed. I know, because I set up code in the
CancelButton assigned button such that, I execute the
DialogResult under certain circumstances and sometimes I
don't but the form kept closing regardless. I had to get
to the point of setting the form to perform KeyPreview to
True of the Form, and removing the CancelButton assignment
and to issue the test/closing of form within the KeyPress
event of the Form whenever the user pressed ESCape.

-Lee
>-----Original Message-----
>* "Lee Moody" <(E-Mail Removed)>

scripsit:
>> If you specify a CancelButton property on a form to a
>> specific button, but you specify 'None' as DialogResult
>> for that button, and you show the form using

ShowDialog,
>> pressing ESCape key is causing the DialogResult to fire
>> and closes the form.

>
>The button will be fired, but no 'DialogResult' will be

set. You can
>set the 'DialogResult' in the cancel button's 'Click'

event handler.
>
>--
>Herfried K. Wagner [MVP]
><URL:http://dotnet.mvps.org/>
>.
>

 
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
form.cancelbutton property issues Nigel V Thomas Microsoft VB .NET 3 4th Oct 2009 02:02 PM
Why CancelButton's OnClientClick cannot be set programmatically in a wizard? Bogdan Microsoft ASP .NET 1 9th Jun 2008 08:02 PM
Bug or Feature? CancelButton vs Escape Key =?Utf-8?B?VGVycnk=?= Microsoft VB .NET 8 20th Jul 2006 09:49 AM
CancelButton & ShowDialog emorgoch.public@gmail.com Microsoft Dot NET Framework Forms 4 6th Jun 2006 12:44 PM
Stopping the CancelButton from closing a Dialog form Oenone Microsoft VB .NET 5 23rd Feb 2005 04:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:01 AM.