0

ドロップダウンアイテムとしてメニューにアイテムを追加するために、フォームをロードしています。

同じサブ内から、メニューストリップのドロップダウンアイテムをmsgboxに出力しようとしましたが、すべてのアイテムに対して空白の応答が返されます。

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

私はこのようなサブでそれを使用します

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
4

1 に答える 1

1

Tagプロパティを使用しているコードを見ると(そこにデータを明示的に設定していない場合は、 TextBox に何も追加されません):

txbList.Text = txbList.Text & ", " & MyMenuItem.Tag

Textプロパティを使用するつもりですか

txbList.Text = txbList.Text & ", " & MyMenuItem.Text
于 2012-06-09T03:17:51.453 に答える