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):
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(); |