Disabling MenuItems
-
Hi there. I have an app that has several menus. I want that when a certain menuItem(s) is/are selected other menuItems are disabled. For instance, if a user selects menuItem2 I want menuItems 10, 12 and 17 to be disabled. How do I go about coding that? I know about Enable = false but I don´t know how to code: if such and such menuItems are selected then such and such menuItems are to be disabled. Thanks, FJ
-
Hi there. I have an app that has several menus. I want that when a certain menuItem(s) is/are selected other menuItems are disabled. For instance, if a user selects menuItem2 I want menuItems 10, 12 and 17 to be disabled. How do I go about coding that? I know about Enable = false but I don´t know how to code: if such and such menuItems are selected then such and such menuItems are to be disabled. Thanks, FJ
-
Are you talking about menu items with CheckBox's ? Something this simple might help: menuItem3.Enabled = (menuItem1.Checked && menuItem2.Checked && ...); Enjoy, David
Hi. No, what I mean is to have a menuItem like Paste grayed out unless you have something on the clipboard, one can´t paste unless something is on the clipboard. Once you have something on the clipboard Paste becomces selectable, not grayed out. I want certain menuItems to be grayed out if some other menuItem is selected. Thanks, FJ
-
Hi. No, what I mean is to have a menuItem like Paste grayed out unless you have something on the clipboard, one can´t paste unless something is on the clipboard. Once you have something on the clipboard Paste becomces selectable, not grayed out. I want certain menuItems to be grayed out if some other menuItem is selected. Thanks, FJ
Hi! You can use the menu's Popup event to enable/disable the menu items of your menu, so if you have a menu
myMenu
you could write the Popup event handler like this:private void myMenu_Popup(object sender, EventArgs e)
{
myMenuItem1.Enabled = SomeFunctionToDecideWhetherMenuItem1IsEnabled();
}or, using the clipboard example:
private void menuEdit_Popup(object sender, EventArgs e)
{
DataObject dob = Clipboad.GetDataObjet();
// Only enable the Paste command if there's Text on the clipboard
menuEditPaste.Enabled = dob.GetDataPresent(DataFormats.Text);
}Regards, mav
-
Hi there. I have an app that has several menus. I want that when a certain menuItem(s) is/are selected other menuItems are disabled. For instance, if a user selects menuItem2 I want menuItems 10, 12 and 17 to be disabled. How do I go about coding that? I know about Enable = false but I don´t know how to code: if such and such menuItems are selected then such and such menuItems are to be disabled. Thanks, FJ
Search for an ActionList component on codeproject, this should help you. 'A programmer is just a tool which converts caffeine into code'
-
Hi! You can use the menu's Popup event to enable/disable the menu items of your menu, so if you have a menu
myMenu
you could write the Popup event handler like this:private void myMenu_Popup(object sender, EventArgs e)
{
myMenuItem1.Enabled = SomeFunctionToDecideWhetherMenuItem1IsEnabled();
}or, using the clipboard example:
private void menuEdit_Popup(object sender, EventArgs e)
{
DataObject dob = Clipboad.GetDataObjet();
// Only enable the Paste command if there's Text on the clipboard
menuEditPaste.Enabled = dob.GetDataPresent(DataFormats.Text);
}Regards, mav
Hi, thanks for your help. I still don´t know how to do this. How can I disable a menuItem when some other menuItem is selected? For instance, if menuItem5 is chosen then I want menuItem11 and menuItem12 to be disabled? How do I do that? Thanks again for your help, FJ
-
Hi, thanks for your help. I still don´t know how to do this. How can I disable a menuItem when some other menuItem is selected? For instance, if menuItem5 is chosen then I want menuItem11 and menuItem12 to be disabled? How do I do that? Thanks again for your help, FJ
private void menuItem5_Clicked(object sender, EventArgs e)
{
menuItem11.Enabled = false;
menuItem12.Enabled = false;
}that's as explicit as I can put it... mav
-
private void menuItem5_Clicked(object sender, EventArgs e)
{
menuItem11.Enabled = false;
menuItem12.Enabled = false;
}that's as explicit as I can put it... mav