本文整理汇总了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