473,387 Members | 1,760 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,387 software developers and data experts.

Key board handling in ContextMenuStrip

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:

GroupMenu1
GroupSubMenu1
Menu2

GroupMenu2
Menu3
Menu4

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
1 1906
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.

Pete
Jun 27 '08 #2

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

Similar topics

1
by: Ron M. Newman | last post by:
I have a context menu strip. I can Add elements to its "Items", but there is nothing in there to add a sub context menu strip. Menu Item 1 Item 2 Sub Item 1 <-- impossible to add! How do...
7
by: Dave | last post by:
How do I get my ContextMenuStrip to receive key down preview events? I have the event hooked but I don't see the key strokes in the event? Dave
5
by: =?Utf-8?B?cHJvZ2dlcg==?= | last post by:
I've written an application that can minimize to the tray and can reappear if you double click on the icon in the tray (ShowInTaskbar is set to false). I've also created a ContextMenuStrip (Visual...
0
by: active | last post by:
For the last 3 or 4 days I've been, on an off, searching the Internet and theVS2005 Doc for an example of how to add a contextmenustrip to a menustrip. I can move all the items from a...
1
by: =?Utf-8?B?QnJhZA==?= | last post by:
i have a menu system that is generated dynamically everything works good except for one minor astetic.... I click on a menu item that displays a ContextMenuStrip Popup Menu If an item on...
7
by: Joe Cool | last post by:
Let's say I have a Treeview control on a form. Each leaf node in the Treeview has a ContextMenuStrip, each with one ToolStripMenuItem, and all ToolStripMenuItems Click event is handled by a comment...
1
by: Tony Johansson | last post by:
Hello! I have a System.Windows.Forms.MenuStrip with some ToolStripMenuItem. One of these ToolStripMenuItem is called saveMemberToolStripMenuItem. This one is defined like this...
9
by: =?Utf-8?B?Z2luYWNyZXNzZQ==?= | last post by:
Hi, I have a form (Form1) with a ContextMenuStrip (ContextMenuStrip1). If I pass Form1 to a Utility Sub with the following code: Public Sub Utility(theForm as Object) with theForm For Each...
2
by: eBob.com | last post by:
I've been working on an app which has an array of RichTextBoxes. And I have a context menu for the RTBs. The context menu has two levels; the first level has two items, "Load Sample Text File"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.