We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Menu Short Cut - Escape Key

Thread ID:

Created:

Updated:

Platform:

Replies:

5509 Jul 7,2003 04:59 AM Jul 10,2003 04:58 AM Windows Forms 5
loading
Tags: FAQ
Lextar
Asked On July 7, 2003 04:59 AM

I've configured my record actions (New, Update, Save etc) to a menu and set short cut keys for them. Now I've been using Ctrl+N for new, Ctrl+U for Update... now for Cancel, it would be Ctrl-C but then that is the short cut key for Cut. I want to set it to Escape key for Cancel, but it is not in the short cut list within the Menu Editor. Is it possible to manually configure it I can detect when the Escape key is pressed without defining it in every text/object box??

Ramesh Praveen [Syncfusion]
Replied On July 9, 2003 03:58 AM

One way is to override ProcessCmdKey in your Form and listen to the Esc key. This should get called where ever the focus is on the form. -Praveen

Lextar
Replied On July 9, 2003 05:50 AM

Erm... how do you do that?

Ramesh Praveen [Syncfusion]
Replied On July 9, 2003 01:58 PM

In your form: //C#: protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if(keyData == Keys.Escape) { //Do something. return true; } return base.ProcessCmdKey(ref msg, keyData); } -Praveen

Lextar
Replied On July 10, 2003 03:27 AM

Doh, I presume that the solution you've given is for C? I should have stated that I'm working with Visual Basic. Does it work with VB?

Ramesh Praveen [Syncfusion]
Replied On July 10, 2003 04:58 AM

' VB.Net Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean If keyData = Keys.Escape Then 'Do something. Return True End If Return MyBase.ProcessCmdKey( msg, keyData) End Function

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;