473,383 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How to add Escape as an accelerator to a menu item?

How does one specify the Escape key as an accelerator?

My client has specified that the Escape key be used as an accelerator for a
particular menu item. In VS05's designer mode, this particular key is not
available as an option to select from the menu item's properties
ShortcutKeys item. "No problem," says I to myself (I talk to myself. It's
the only way I can have an intelligent conversation around here. Or at least
a coherent one, but that's a tale for another time...) "I'll just go into
the form's designer.cs file and manually enter

this.mnuEdit_DeselectAl.ShoartcutyKeys =
((System.Windows.Forms.Kyes)System.WIndows.Forms.K eys.Escape);

Only then the design view doesn't come up any more. It says that 27 is an
illegal value. So, is it possible to specify the Escape key as an
accelerator or does VS05 preclude this option? If possible, what am I doing
wrong?

--
Richard Lewis Haggard
www.Haggard-And-Associates.com
Dec 4 '06 #1
2 2499
Maybe you should use a different key. I believe the Escape key
is used as a Cancel or Undo button almost universally. Having
it do something different is sort of counterintuitive.

Robin S.
------------------------
"Richard Lewis Haggard" <HaggardAtWorldDotStdDotComwrote in message
news:%2***************@TK2MSFTNGP02.phx.gbl...
How does one specify the Escape key as an accelerator?

My client has specified that the Escape key be used as an accelerator for
a particular menu item. In VS05's designer mode, this particular key is
not available as an option to select from the menu item's properties
ShortcutKeys item. "No problem," says I to myself (I talk to myself. It's
the only way I can have an intelligent conversation around here. Or at
least a coherent one, but that's a tale for another time...) "I'll just go
into the form's designer.cs file and manually enter

this.mnuEdit_DeselectAl.ShoartcutyKeys =
((System.Windows.Forms.Kyes)System.WIndows.Forms.K eys.Escape);

Only then the design view doesn't come up any more. It says that 27 is an
illegal value. So, is it possible to specify the Escape key as an
accelerator or does VS05 preclude this option? If possible, what am I
doing wrong?

--
Richard Lewis Haggard
www.Haggard-And-Associates.com

Dec 4 '06 #2
Richard Lewis Haggard wrote:
How does one specify the Escape key as an accelerator?

My client has specified that the Escape key be used as an accelerator for a
particular menu item. In VS05's designer mode, this particular key is not
available as an option to select from the menu item's properties
ShortcutKeys item. "No problem," says I to myself (I talk to myself. It's
the only way I can have an intelligent conversation around here. Or at least
a coherent one, but that's a tale for another time...) "I'll just go into
the form's designer.cs file and manually enter

this.mnuEdit_DeselectAl.ShoartcutyKeys =
((System.Windows.Forms.Kyes)System.WIndows.Forms.K eys.Escape);

Only then the design view doesn't come up any more. It says that 27 is an
illegal value. So, is it possible to specify the Escape key as an
accelerator or does VS05 preclude this option? If possible, what am I doing
wrong?
Firstly I'd try and educate your client in the fine art of usability,
but failing that, you could use the Form.KeyPress event to trap the
Escape key being pressed and fire the menuitem's click event.

private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == Convert.ToChar(Keys.Escape))
{
showMessageEscToolStripMenuItem_Click(this, new EventArgs());
}
}

private void showMessageEscToolStripMenuItem_Click(object sender,
EventArgs e)
{
MessageBox.Show("Escape");
}

Don't forget to set the MenuItem's ShortcutKeyDisplayString property to Esc!

Dec 4 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at...
10
by: tmaster | last post by:
When I try to dynamically add a second sub menu item to this ContextMenu item, I get an error 'Specified argument was out of the range of valid values'. Private Sub mnuTopics_Show_Select(ByVal...
6
by: MONROUX philippe | last post by:
hi, In a file.xsl I have : ====================================================================== .... <xsl:variable name="LANGS" select="path"/> <xsl:template match="@*|node()">...
4
by: Bob Homes | last post by:
In VB6, I used a system, which I loved, whereby I assigned a "helpId" to each menu item; that way, you could rest the cursor on the item (without actually running it) and then press F1 to get...
2
by: B. | last post by:
I have a C# winform with accelerator key associated with some menus. If my exe is in unmanaged C++ and the winform is invoked through interop, the accelerator key not working. If I create a new...
4
by: ayan4u | last post by:
ok i have a main window hWnd and created an edit dialogue box as a child window(gEditBox) i have an acclerator table to access the menu items in hWnd when i am in the edit box nothing happens...
2
by: killy971 | last post by:
I have been testing different libraries to process XSL transformations on large XML files. The fact is that I read a document from Intel, stating their library (XSLT accelerator) was more twice...
4
by: stuckagain | last post by:
Hi, I have a page with a scrollable DIV, and within that DIV, I have a few asp.net menu controls. The idea being, the user mouses over the small icons and is presented with a list of options. ...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.