本文整理汇总了VB.NET中System.Windows.Forms.MenuItem.PerformClick方法的典型用法代码示例。如果您正苦于以下问题:VB.NET MenuItem.PerformClick方法的具体用法?VB.NET MenuItem.PerformClick怎么用?VB.NET MenuItem.PerformClick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.MenuItem
的用法示例。
在下文中一共展示了MenuItem.PerformClick方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: CreateMyMenu
Public Sub CreateMyMenu()
' Create a main menu object.
Dim mainMenu1 As New MainMenu()
' Create empty menu item objects.
Dim menuItem1 As New MenuItem()
Dim menuItem2 As New MenuItem()
' Set the caption of the menu items.
menuItem1.Text = "&File"
menuItem2.Text = "&Edit"
' Add the menu items to the main menu.
mainMenu1.MenuItems.Add(menuItem1)
mainMenu1.MenuItems.Add(menuItem2)
' Add functionality to the menu items.
AddHandler menuItem1.Click, AddressOf Me.menuItem1_Click
AddHandler menuItem2.Click, AddressOf Me.menuItem2_Click
' Assign mainMenu1 to the form.
Me.Menu = mainMenu1
' Perform a click on the File menu item.
menuItem1.PerformClick()
End Sub
Private Sub menuItem1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
MessageBox.Show("You clicked the File menu.", "The Event Information")
End Sub
Private Sub menuItem2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
MessageBox.Show("You clicked the Edit menu.", "The Event Information")
End Sub