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

Disable MenuItem Shortcut

Hi,

the application I am writing has a MainMenu and a DataGrid
(UltraGrid).

Now I have to edit the text of each cell in this grid. So far so good.
All works fine in editmode but if I press a key which is also a
shortcut it doesn´t work and the menuitem-clickevent will be
performed.

KeyPreview of each parent form and each mdiparent is disabled.

For example: There is a shortcut in the menu which will be called by
pressing the delete key. If I am in editmode of a cell and I press
this key the shortcut should not be called but the text in this cell
should be edited.

So I tried to remove the shortcut like following code of my own
datagrid (inherits UltragGrid respectively DataGrid):

**** CODE ****
/// <summary>
/// Disable all shortcuts in all superior forms
/// </summary>
/// <param name="oShortcut">The shortcut which has to be
disabled</param>
public void DisableFrmShorcut(Shortcut oShortcut)
{
//Find parent form
Control oControl = this.Parent;
while(!(oControl is frmEnhanced))
{
oControl = oControl.Parent;
}
while(oControl != null)
{
for(int i = 0; i <((frmEnhanced)oControl).Menu.MenuItems.Count; i++)
{
//Find an remove all shortcut which is equal oShortcut
this.RemoveMenuShortcuts(((frmEnhanced)oControl).M enu.MenuItems[i],oShortcut);
}
//Is there another superior form (maybe mdiparent)
oControl = oControl.Parent;
while(!(oControl is frmEnhanced) && oControl != null)
{
oControl = oControl.Parent;
}
}
}
/// <summary>
/// Search every subordinate menuitem and disable the shortcut
/// </summary>
/// <param name="oItem"></param>
/// <param name="oShortcut">The shortcut which has to be
disabled</param>
private void RemoveMenuShortcuts(MenuItem oItem,Shortcut oShortcut)
{
for(int i = 0; i < oItem.MenuItems.Count;i++)
{
//recursive call of this method to find all menuitems
this.RemoveMenuShortcuts(oItem.MenuItems[i],oShortcut);
}
if(oItem.Shortcut == oShortcut)
{
//Remove Shortcut ans disable menuitem
oItem.Shortcut = Shortcut.None;
oItem.Enabled = false;
//Remember all disabled shortcuts
this._aDisabledShortcuts.Add(oShortcut);
}
}
**** CODE END ****

When I am entering the editmode of each cell I call the first methode
above to disable the shortcuts. This works fine and the menuitem(s)
are disabled and the shortcuts arent displayed in the menu but the
menuitem-clickevent will be performed again and agian.

Does anyone have an idea how I can resolve this problem??? I would be
very glad if someone can help me!

Best regards

Marcel Stallmach

hope you understand my english and what I mean ;)
Nov 16 '05 #1
0 2725

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

Similar topics

10
by: Lex | last post by:
I am writing a C# app that has a Menu. Some of the menu items will have short cuts that do not exist in the Shortcut enum. I would like the custom shortcuts to appear on the menu but as far as I...
5
by: Lex | last post by:
As you may have seen in other posts I have a C# app that has custom shortcuts so I need to OwnerDraw my MenuItems. Thanx to vJ and Mick for the tips so far. I am almost there :-) My last (I...
6
by: Claus Holm | last post by:
I'm trying to enable a menuitem in the parent form from a mdichild. Rather than making the menuitems public, I'd go for a public method in the parent form to do the change, but when I call the...
3
by: Stilgar[bbs.isca.uiowa.edu] | last post by:
Here's my newbie question: I have several VB forms which are all inherit a standard template form that I made. In my template form, I added a menu bar with some generic cut, copy, and paste...
5
by: Brian Henry | last post by:
I have a form with a main menu on it (mdi parent form) and i have a child form with a menu and I am mergeing the menus together for the menu called reports.. now when i do this they merge just...
1
by: Michael | last post by:
Hi Everyone, I seem to be having a problem accessing a menuitem on the MDIParent from a child form. From a login (frmSecurity -child form) screen, I need to hide a menuitem based on the users...
0
by: Locusta | last post by:
Hello, I'm generating a MainMenu in c# from a dataset, and one of the fields is the shortcut. How can I add something like this: if (dr.ToString() != string.Empty) m_menuitem.Shortcut =...
1
by: inadsad | last post by:
Good Day, I have 2 forms with bindingNavigator and have a simple routine to enable/disable navigator buttons. Each nav button is assigned to a tag value. The problem is that if I want to...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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.