當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET MenuItem構造函數代碼示例

本文整理匯總了VB.NET中System.Windows.Forms.MenuItem.MenuItem構造函數的典型用法代碼示例。如果您正苦於以下問題:VB.NET MenuItem構造函數的具體用法?VB.NET MenuItem怎麽用?VB.NET MenuItem使用的例子?那麽, 這裏精選的構造函數代碼示例或許可以為您提供幫助。您也可以進一步了解該構造函數所在System.Windows.Forms.MenuItem的用法示例。


在下文中一共展示了MenuItem構造函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。

示例1: CreateMyMenu

Public Sub CreateMyMenu()
    ' Create an empty menu item object.
    Dim menuItem1 As New MenuItem()
    ' Intialize the menu item using the parameterless version of the constructor.
    ' Set the caption of the menu item.
    menuItem1.Text = "&File"
End Sub
開發者ID:VB.NET開發者,項目名稱:System.Windows.Forms,代碼行數:7,代碼來源:MenuItem

示例2: CreateMyMenus

Public Sub CreateMyMenus()
    ' Create an instance of a MenuItem with a specified caption.
    menuItem1 = New MenuItem("&File")
End Sub
開發者ID:VB.NET開發者,項目名稱:System.Windows.Forms,代碼行數:4,代碼來源:MenuItem

示例3: CreateMyMenuItem

Public Sub CreateMyMenuItem()
    ' Create an instance of MenuItem with caption and an event 
    ' handler
    Dim MenuItem1 As New MenuItem("&New", New _
        System.EventHandler(AddressOf Me.MenuItem1_Click))
End Sub
' This method is an event handler for MenuItem1 to use when 
' connecting its event handler.
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal _
    e as System.EventArgs)
    ' Code goes here that handles the Click event.
End Sub
開發者ID:VB.NET開發者,項目名稱:System.Windows.Forms,代碼行數:12,代碼來源:MenuItem

示例4: CreateMyMenuItem

Public Sub CreateMyMenuItem()
    ' submenu item array.
    Dim subMenus(3) As MenuItem
    ' Create three menu items to add to the submenu item array.
    Dim subMenuItem1 As New MenuItem("Red")
    Dim subMenuItem2 As New MenuItem("Blue")
    Dim subMenuItem3 As New MenuItem("Green")
    ' Add the submenu items to the array.
    subMenus(0) = subMenuItem1
    subMenus(1) = subMenuItem2
    subMenus(2) = subMenuItem3
    ' Create an instance of a MenuItem with caption and an array of submenu
    ' items specified.
    Dim MenuItem1 As New MenuItem("&Colors", subMenus)
End Sub
開發者ID:VB.NET開發者,項目名稱:System.Windows.Forms,代碼行數:15,代碼來源:MenuItem

示例5: CreateMyMenuItem

Public Sub CreateMyMenuItem()
    ' Create a MenuItem with caption, shortcut key, and an event handler
    ' specified.
    Dim MenuItem1 As New MenuItem("&New", _
       New System.EventHandler(AddressOf Me.MenuItem1_Click), Shortcut.CtrlL)
End Sub    
   
' The following method is an event handler for menuItem1 to use when
' connecting the event handler.
Private Sub MenuItem1_Click(sender As Object, e As EventArgs)
    ' Code goes here that handles the Click event.
End Sub
開發者ID:VB.NET開發者,項目名稱:System.Windows.Forms,代碼行數:12,代碼來源:MenuItem

示例6: CreateMyMenuItem

Public Sub CreateMyMenuItem()
   ' Submenu item array.
   Dim SubMenus(3) as MenuItem
   ' Create three menu items to add to the submenu item array.
   Dim SubMenuItem1, SubMenuItem2, SubMenuItem3 as MenuItem
   SubMenuItem1 = New MenuItem ("Red")
   SubMenuItem2 = New MenuItem ("Blue")
   SubMenuItem3 = New MenuItem ("Green")
   ' Add the submenu items to the array.
   SubMenus(0) = SubMenuItem1
   SubMenus(1) = SubMenuItem2
   SubMenus(2) = SubMenuItem3
   ' Create a MenuItem with caption, shortcut key, 
   ' a Click, Popup, and Select event handler, menu merge type and order, and an 
   ' array of submenu items specified.
   Dim MenuItem1 As MenuItem
   MenuItem1 = New MenuItem(MenuMerge.Add, 0, Shortcut.CtrlShiftC, "&Colors", _
      AddressOf Me.MenuItem1_Click, _
      AddressOf Me.MenuItem1_Popup, _
      AddressOf Me.MenuItem1_Select, SubMenus)
End Sub

' The following method is an event handler for MenuItem1 to use  when connecting the Click event.
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal  e as System.EventArgs)
   ' Code goes here that handles the Click event.
End Sub

' The following method is an event handler for MenuItem1 to use  when connecting the Popup event.
Private Sub MenuItem1_Popup(ByVal sender As System.Object, ByVal  e as System.EventArgs)
   ' Code goes here that handles the Click event.
End Sub

' The following method is an event handler for MenuItem1 to use  when connecting the Select event
Private Sub MenuItem1_Select(ByVal sender As System.Object, ByVal  e as System.EventArgs)
   ' Code goes here that handles the Click event.
End Sub
開發者ID:VB.NET開發者,項目名稱:System.Windows.Forms,代碼行數:36,代碼來源:MenuItem


注:本文中的System.Windows.Forms.MenuItem.MenuItem構造函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。