SpeakComputers.com online store
Electronics Software Computers Handhelds Laptops and Tablets Mobile Phones Digital Cameras Camcorders Games Music Books Sport Mens and Womens Watches Power Tools Household appliances
Software Downloads 2012 Software Mac Software Security Student Editions Windows 7 Office 2010

VB.NET MenuStrip Control.

The VB.NET Windows MenuStrip control provides an application menu system. The menustrip works with both Single document interfaces SDI and Multiple document interfaces MDI. With MDI applications the MenuStrip can be configured to merge with the main form for better navigation.

Namespace: System::Windows::Forms
System.Windows.Forms (in system.windows.forms.dll)

Creating an new VB.NET Windows forms MenuStrip.
Dim menustrip As New MenuStrip

Assigning a new location for the VB.NET Windows Forms MenuStrip.
menustrip.Location = New Point(0, 0)

Assigning a size value to the VB.NET MenuStrip.
menustrip.Size = New Size(Me.Width, 24)

Now we need to add menuitems to the menustrip control. The items I am speaking about are the dropdown menus, File, Edit, Windows etc, and the clickable button items within the menus, Open, Save, SaveAS etc.

Adding the first menu item - MenuStripItem.
Dim menuitem1 As New ToolStripMenuItem

Assigning a text value to the MenuStripItem
menuitem1.Text = "File"

Adding an image to the MenuStripItem.
menuitem1.Image = Image.FromFile("e:\file.png")

Now we add the first MenuStripItem to the MenuStrip itself.

Next we are going to add a second MenuStripItem but we are going to add it to the first MenuStripItem as a dropdown item.
Dim menuitem2 As New ToolStripMenuItem
menuitem2.Text = "Exit"

Adding menuitem2 as a DropDown Menu item.

Adding a VB.NET MenuStrip control to the form.

Assign the MainMenuStrip to the form.
Me.MainMenuStrip = menustrip

Creating a Click Event for the VB.NET MenuStripItem control.
AddHandler menuitem2.Click, AddressOf menuitem2_click

Responding to the VB.NET MenuStripItem Click event.
Private Sub menuitem2_click(ByVal sender As Object, ByVal e As EventArgs)
MessageBox.Show("Menuitem Clicked")
End Sub

VB.NET MenuStrip control Tutorial.
Home About Privacy Policy Resouces Products Map

Copy Right 2006 SpeakComputers.com - All Rights Reserved.
Learn Spanish
Learn Spanish for free with our online and free tutorials with audio. See our grammar sections, verb sections and drills, massive vocabulary sections with audio, our Spanish verb conjugator and more.
Free Text to Speech Software
Get software that makes your computer read text aloud.
Text to Speech software that supports natural sounding TTS voices.
Convert text to MP3 files
Listen to webpages aloud or convert them to sound files