我在表单加载时将项目作为下拉项目添加到菜单中。
从同一个子中,我尝试在 msgbox 中输出 menustrip 下拉项目,但我的所有项目都得到空白响应。
Private Sub PopulateLoadChildMenu()
msItemLoad.DropDownItems.Clear()
Dim fi As FileInfo
If Directory.GetFiles(_playlistpath).Length > 1 Then
msItemLoad.Enabled = True
End If
For Each fi In _files
msItemLoad.DropDownItems.Add(Path.GetFileNameWithoutExtension(_playlistpath & fi.Name))
Next
For Each MyMenuItem As ToolStripMenuItem In msItemLoad.DropDownItems
txbList.Text = txbList.Text & ", " & MyMenuItem.Tag
Next
End Sub
我在这样的 Sub 中使用它
Private Sub FormLoad(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim fi As FileInfo
msItemLoad.Enabled = False
If Directory.GetFiles(_playlistpath).Length = 1 Then
For Each fi In _files
LoadPlaylist(_playlistpath & fi.Name)
Next
End If
PopulateLoadChildMenu()
End Sub