Creating Menu in Visual Basic .NET

Last Updated: March 19, 2020

In this example, we will see how to create the Menu in VB.NET
You can drag a MenuStrip control from the ToolBox drop it on the Form
Now you can type on the Menu and you can create sub menu or menu with same level. Creating menu in designer mode is very straight forward

Following figure shows the menu creation in design mode

Menu Design Mode

Now you can change the properties of a menu using the property window

Menu Property Windpw

To add short cut for menu you can use ShortCutKeys property of the menu. I have crated a ShortCut here Ctrl+Shift+O for menu item Open

You can use this property windows to add image, add check box to the menu

Fowling figure shows a Form added simple menu system. This is in run time
Menu Demo Run

This is the code for click events of the menu

Public Class Form1

    Private Sub NewToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles NewToolStripMenuItem.Click

    End Sub

    Private Sub ProjectAToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ProjectAToolStripMenuItem.Click
        ProjectAToolStripMenuItem.Checked = True
    End Sub
End Class

Code explanation

  • Line 3: Click event handler of the New menu is to display a Message Box
  • Line 8: Click event handler of the New menu is to display the CheckBox