VB.Net - Menu Control

A menu is located on the menu bar and contains a list of related commands. MainMenu is the container for the Menu structure of the form and menus are made of MenuItem objects that represent individual parts of a menu.

You can create a main menu object on your form using the MainMenu control. The following picture shows how to drag the Menustrip Object to the Form.

vb.net-menu-control.jpg

After drag the Menustrip on your form you can directly create the menu items by type a value into the "Type Here" box on the menubar part of your form. From the following picture you can understand how to create each menu items on mainmenu Object.

vb.net-menubar.jpg

If you need a separator bar , right click on your menu then go to insert->Separator.

vb.net-menu-seperator.jpg

After creating the Menu on the form , you have to double click on each menu item and write the programs there depends on your requirements. The following Vb.Net program shows how to show a messagebox when clicking a menu item.

 

Public Class Form1

    Private Sub MenuItem1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1ToolStripMenuItem.Click

        MsgBox("You are selected MenuItem_1")

    End Sub

End Class
Next Post Previous Post
No Comment
Add Comment
comment url