ComponentOne Menus and Toolbars for WinForms
Deleting Menu Items
Menus and Toolbars for WinForms Task-Based Help > Menu Tasks > Deleting Menu Items

When a menu item is highlighted, and you press the DEL key or select delete from the context menu, either the command link or the command (simple or menu) linked by that link can be deleted, depending on which one is currently selected. (To check what is currently selected, look at the Properties window of the Visual Studio designer.)

To delete a menu item at design time

To delete the command link (this will leave the command, so that you can link to it from another command link):

  1. Click once on the menu item you want to delete. Make sure that the Properties window shows the properties of the command link and not the command.
  2. Right-click on the item to open the context menu and select delete or simply press the DEL key.
    To delete the command itself (this will remove the command but leave the command link so that you'll be able to link it to another command or menu):
  3. Click on the menu item you want to delete. Then click on it again. This action will select the command rather than the command link. Make sure that the Properties window shows the properties of the command and not the command link.
  4. Right-click on the item to open the context menu and select delete, or simply press the DEL key. The command will be deleted and the now empty command link will be left. You can re-link it to another command by right-clicking on it and selecting edit from the context menu.

To delete a menu item programmatically

To delete the menu, use the Dispose method. Use the following code to delete the menu or menu item:

To write code in Visual Basic

Visual Basic
Copy Code
'The variable name for the menu is called menu
'This deletes the menu
menu.Dispose()
 
'The variable name for the menu item is called menuitem1
'This deletes the menu item
menuitem1.Dispose()

To write code in C#

C#
Copy Code
//The variable name for the menu is called menu
//This deletes the menu
menu.Dispose();
 
//The variable name for the menu item is called menuitem1
//This deletes the menu item
menuitem1.Dispose();
See Also