Adding Icons In MenuItems In Vb.Net
Posted On December 26, 2007 by GB Shah filed under
The following class is responsible for providing a type of MenuItem object which can contain an Icon along with the Name and Shortcut and EventHandler for it. Create an object of the following class and use it as the way as you use in case of default MenuItem objects.
Here goes the class.
| Public Class MyIconMenuItem Inherits MenuItem End Sub Protected Overrides Sub OnMeasureItem(ByVal e As MeasureItemEventArgs) br.Dispose() Private Function AppendShortcut() As String |
For the sake of understanding I am providing a sample code snippet on how to work with the class.
Just copy and paste the code in a module and call the following sub from the click event of a button. You can also call the sub from the Load event of the form. Basically you can call it from almost any event of the windows form and its controls.
Here goes the example.
| Public Sub CreateMyIconMenu() ' Create a main menu object. 'while creating the icon replace the icon path with your own values Me.Menu = mainMenu1 'Add functionality to the menu items using the Click event. |
This simple article is really cool is not it. Best of luck to all. HAPPY CODING.
