本文整理汇总了VB.NET中System.Windows.Forms.Menu.GetContextMenu方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Menu.GetContextMenu方法的具体用法?VB.NET Menu.GetContextMenu怎么用?VB.NET Menu.GetContextMenu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Menu
的用法示例。
在下文中一共展示了Menu.GetContextMenu方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: AddContextmenu
Public Sub AddContextmenu()
' Create a shortcut menu.
Dim m As New ContextMenu()
Me.ContextMenu = m
' Create MenuItem objects.
Dim menuItem1 As New MenuItem()
Dim menuItem2 As New MenuItem()
' Set the Text property.
menuItem1.Text = "New"
menuItem2.Text = "Open"
' Add menu items to the MenuItems collection.
m.MenuItems.Add(menuItem1)
m.MenuItems.Add(menuItem2)
' Display the starting message.
MessageBox.Show("Right-click the form to display the shortcut menu items")
' Add functionality to the menu items.
AddHandler menuItem1.Click, AddressOf Me.menuItem1_Click
AddHandler menuItem2.Click, AddressOf Me.menuItem2_Click
End Sub
Private Sub menuItem1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim textReport As String = "You clicked the New menu item. " + vbCr + "It is contained in the following shortcut menu: " + vbCr + vbCr
' Get information on the shortcut menu in which menuitem1 is contained.
textReport += ContextMenu.GetContextMenu().ToString()
' Display the shortcut menu information in a message box.
MessageBox.Show(textReport, "The ContextMenu Information")
End Sub
Private Sub menuItem2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim textReport As String = "You clicked the Open menu item. " + vbCr + "It is contained in the following shortcut menu: " + vbCr + vbCr
' Get information on the shortcut menu in which menuitem1 is contained.
textReport += ContextMenu.GetContextMenu().ToString()
' Display the shortcut menu information in a message box.
MessageBox.Show(textReport, "The ContextMenu Information")
End Sub