Private Sub Form9_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load
MenuStrip1.Items.Add("文件",Nothing,AddressOf menuItem_Click).Name = "mnuFile"
MenuStrip1.Items.Add("编辑",AddressOf menuItem_Click).Name = "mnuEdit"
Dim doItem As ToolStripMenuItem = MenuStrip1.Items("mnuFile")
doItem.DropDownItems.Add("打开",AddressOf menuItem_Click).Name = "mnuOpen"
doItem.DropDownItems.Add("保存",AddressOf menuItem_Click).Name = "mnuSave"
End Sub
Private Sub menuItem_Click(ByVal sender As Object,ByVal e As System.EventArgs) Handles MenuStrip1.Click
Try
Select Case sender.name
Case "mnuFile"
MsgBox("文件")
Case "mnuEdit"
MsgBox("编辑")
Case "mnuOpen"
MsgBox("打开")
Case "mnuSave"
MsgBox("保存")
End Select
Catch ex As Exception
End Try
End Sub
原文链接:https://www.f2er.com/vb/259617.html