473,722 Members | 2,319 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 DisableFrmShorc ut(Shortcut oShortcut)
{
//Find parent form
Control oControl = this.Parent;
while(!(oContro l 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.RemoveMenu Shortcuts(((frm Enhanced)oContr ol).Menu.MenuIt ems[i],oShortcut);
}
//Is there another superior form (maybe mdiparent)
oControl = oControl.Parent ;
while(!(oContro l 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 RemoveMenuShort cuts(MenuItem oItem,Shortcut oShortcut)
{
for(int i = 0; i < oItem.MenuItems .Count;i++)
{
//recursive call of this method to find all menuitems
this.RemoveMenu Shortcuts(oItem .MenuItems[i],oShortcut);
}
if(oItem.Shortc ut == oShortcut)
{
//Remove Shortcut ans disable menuitem
oItem.Shortcut = Shortcut.None;
oItem.Enabled = false;
//Remember all disabled shortcuts
this._aDisabled Shortcuts.Add(o Shortcut);
}
}
**** 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 2784

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

Similar topics

10
2578
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 can tell there is no way to add a short cut that is not in the Shortcut enum. I have my on keyboard hook so I am not worried about the custom shortcut magically working. I just want it to appear nicely formated on the menu. Anyone have any...
5
1932
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 hope) issue is aligning the menu text and shortcut text properly. I need it to line up as if there are two columns - 1 for the menu text and one for the shortcut text. The menu text is left justified in col 1 and shortcur text is left justified...
6
6222
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 method from the mdichild, I get this error: C:\MyProjects\Visual Studio Projects\Tournament\Forms\frmLogin.cs(69): The name 'test' does not exist in the class or namespace 'Tournament.frmLogin' frmLogin is the mdichild.
3
6688
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 functionality. I'd like to have the paste button disabled when the clipboard is empty, but I'm not sure how I should do this. Ideally, I suppose I'd like to constantly monitor the clipboard for data, (in a thread?) but I'm not even sure how I'd...
5
1527
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 fine.. but i need to disable the menu when the user logs out of the system or clear it so they cant run reports still after logout. but when i try to set the mdi parent's menu's mnuReports item's enabled property to false it throws an item isnt set to...
1
2395
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 role. The problem is that I can't seem to get access to the menuitem. I can't get it with code like: MDIParent.mnuAdministrator.Visible = true MDIParent is the name of the form I gave. This is also the Startup form (in the project settings) if this...
0
445
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 = dr.ToString(); I'm sure that the above code doesn't work, but I'm a junior C# developer so I need some help here...
1
2064
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 enable/disable multiple nav buttons I have to call the routine twice. EnableDisableNavBtn(NavMain, NavMain.Item(1), false) EnableDisableNavBtn(NavMain, NavMain.Item(2), false) ...
0
8861
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9383
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9236
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9154
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9088
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8051
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.