By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,954 Members | 1,592 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,954 IT Pros & Developers. It's quick & easy.

Key board handling in ContextMenuStrip

P: n/a
Hi All,
1. I have a context menu with some items in it. I have not assigned
any key board shortcuts to any menu item. Now when the context menu is
open and some key (say 'a') is pressed and if context menu contains
only one menu item whose text starts with 'a' then it triggers action
for that menu item.
At the same time if more than one item with name starting from 'a'
exists then it toggles the focus on pressing 'a' and not triggers any
action for any menu item.
It seems to be the default behavior of context menus.

->Now I want to disable this (default) key board handling of context
menus. How can I do it??

2. I have another context menu which contains various menu items. Some
items are just groups items, which simple does nothing apart from
grouping same category menu items. For example consider the following
menu structure:



No action handling is done for GroupMenu1 and GroupMenu2 as they are
not meant to be. So no handling is done for them and at the same time
code is written for not closing the context menu when any of the
GroupMenu option is clicked and not to highlight them as I am using
custom menu rendering. Now when context menu is opened and 'G' is
pressed multiple times then 'GroupSubmenu1' gets highlighted every
third time when 'G' is pressed. It seems that two 'G' were
highlighting the GroupMenu1 and GroupMenu2.
->Now I want to stop it and want that pressing 'G' multiple times
should only highlight GroupSubMenu1 each time.

Sorry for the bulky post and Thanks!!
Jun 27 '08 #1
Share this Question
Share on Google+
1 Reply

P: n/a
On Thu, 19 Jun 2008 03:13:16 -0700, Mohit <mo*********@gmail.comwrote:
->Now I want to disable this (default) key board handling of context
menus. How can I do it??
I haven't tried this, but since ContextMenuStrip inherits Control, you can
probably use the same key-handling methods that would be used for other
control classes in this case. Override the key-handling methods and use
whatever interception technique is appropriate (some require that you not
call the base handler, others have a "Handled" or "Cancel" property in the
event args you can set...I didn't have time to review the specifics for
you, but you should be able to figure it out).

As for your second question, given that the problem seems to be a
side-effect of some specific control customization you've done, I suspect
you'll need to post a concise-but-complete code sample that reliably
demonstrates the problem. I don't have any immediate ideas off-hand
regarding that question.

Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.