本文整理匯總了VB.NET中System.Windows.Forms.Menu類的典型用法代碼示例。如果您正苦於以下問題:VB.NET Menu類的具體用法?VB.NET Menu怎麽用?VB.NET Menu使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Menu類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: CreateMyMenu
Public Sub CreateMyMenu()
' Set the caption for the top-level menu item.
menuItem1.Text = "Edit"
' Set the caption for the first submenu.
menuItem2.Text = "Font Size"
' Set the caption for menuItem2's first submenu.
menuItem3.Text = "Small"
' Set the checked property to true since this is the default value.
menuItem3.Checked = True
' Define a shortcut key combination for the menu item.
menuItem3.Shortcut = Shortcut.CtrlS
' Set the caption of the second sub menu item of menuItem2.
menuItem4.Text = "Large"
' Define a shortcut key combination for the menu item.
menuItem4.Shortcut = Shortcut.CtrlL
' Set the index of the menu item so it is placed below the first submenu item.
menuItem4.Index = 1
' Add menuItem3 and menuItem4 to menuItem2's list of menu items.
menuItem2.MenuItems.Add(menuItem3)
menuItem2.MenuItems.Add(menuItem4)
' Add menuItem2 to menuItem1's list of menu items.
menuItem1.MenuItems.Add(menuItem2)
' Add menuItem1 to the MainMenu for displaying.
mainMenu1.MenuItems.Add(menuItem1)
End Sub