0

同様の質問をする投稿をいくつか見ましたが、コードで回答を正常に複製できませんでした。次のコードは、項目とその値のメンバーをリスト ボックスに追加します。

Public Shared Sub ListFiles(hTab As Hashtable)
    Debug.Print("create file and key" & Now)
    Dim Enumerator As IDictionaryEnumerator
    Enumerator = hTab.GetEnumerator()

    Dim MyKeys As ICollection
    Dim Key As Object
    MyKeys = hTab.Keys()

    If (hTab.Count > 0) Then
        For Each Key In MyKeys
            Dim sfileName As String = hTab(Key)
            Dim first As Integer = sfileName.IndexOf("_")
            Dim last As Integer = sfileName.LastIndexOfAny("_")
            Dim first2 = (first + 1)
            Dim splitFile = sfileName.Substring(first2)
            frmViewFiles.ListBox1.Items.Add(splitFile)
            frmViewFiles.ListBox1.ValueMember = Key
            frmViewFiles.ListBox1.SelectedValue = Key


        Next
    End If
End Sub

コードを実行して選択したアイテムの値メンバーを取得すると、選択 Dim file = ListBox1.ValueMember.ToString() した最初のアイテムにアクセスできますが、その後の選択では値メンバーが選択したアイテムの値メンバーに変更されません。

私に指示してください。

回答ありがとうございます。これは私の新しいコードです:

Public Shared Sub runListFiles(CustomerId As String)

    Dim cfp As New CloudFilesProvider(cloudId)
    Dim containerObjectList As IEnumerable(Of ContainerObject) = cfp.ListObjects(container:="EstherTest", identity:=cloudId, prefix:=CustomerId & "_")
   For Each file As ContainerObject In containerObjectList
        Dim sFullFileName As String = file.Name
        Dim first As Integer = sFullFileName.IndexOf("_")
        Dim first2 = (first + 1)
        Dim splitFile = sFullFileName.Substring(first2)
        'frmViewFiles.ListBox1.Items.Add(splitFile)
        'frmViewFiles.ListBox1.ValueMember = sFullFileName

        Dim fb = New myFile
        fb.FileName = splitFile
        fb.FullPath = sFullFileName


        frmViewFiles.ListBox1.Items.Add(fb)

        frmViewFiles.ListBox1.DisplayMember = fb.FileName   
        frmViewFiles.ListBox1.ValueMember = fb.FullPath

これは私のクラスです:

Public Class myFile

Public Property FileName As String
Public Property FullPath As String

Public Sub New(f As String, b As String)
    FileName = f
    FullPath = b

End Sub

クラス終了

以下の私のコメントを見て、助けてください

4

2 に答える 2