|
-
Mar 7th, 2007, 03:30 AM
#1
Thread Starter
Lively Member
escape key for a dailog result
hi
i created a dialog result
DialogResult Result = new DialogResult();
Result = MessageBox.Show("Are you sure you want to show the screen?", "", MessageBoxButtons.YesNo);
if (Result == DialogResult.Yes)
{
form2 f2=new form2();
f2.show();
}
if (Result == DialogResult.No)
{
MessageBox.Show " you are in form1";
}
After getting confirmation message if i click escape button i should get the Result with "NO"
how to capture DialogResult keydown event
Regards
Vinay Kumar
-
Mar 7th, 2007, 04:52 AM
#2
Re: escape key for a dailog result
Firstly, DialogResult is an enumeration. You don't use constructors to create enumerated values. Change this:
c# Code:
DialogResult Result = new DialogResult();
to this:Secondly, you're using the wrong buttons on your MessageBox. When you are asking the user to confirm an action that they've already asked for you don't use YesNo but rather OKCancel.
Finally, only a Cancel button on a MessageBox gets clicked automatically when the user presses the Escape key. If your MessageBox is showing YesNo then the user has to click the No button themselves. Fortunately for you, you will be using OKCancel for the reason I specified above so the user can use the Escape key to click the Cancel button.
-
Mar 7th, 2007, 06:30 AM
#3
Thread Starter
Lively Member
Re: escape key for a dailog result
hi
Thanks for the reply. i resolved the issue.
thank u once again for helping me in resolving this issue
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|