Credo di aver capito il problema, tu imposti dirrettamente l'arraylist come datasource e quindi nella proprietà ValueMember non c'è mai niente, ti allego un pò di codice che dovrebbe chiarirti un pò la situazione
'creo prima una classe film con le proprità che mi servono
'in questo esempio c'è anche genere che sulla listbox non mostrerò
Public Class Film
Private FilmName As String
Private IDFilm As Integer
Private GenereFilm As String
Public Sub New(ByVal name As String, ByVal id As Integer, ByVal genere As String)
FilmName = name
IDFilm = id
GenereFilm = genere
End Sub
Public ReadOnly Property Name() As String
Get
Return FilmName
End Get
End Property
Public ReadOnly Property Id() As Integer
Get
Return IDFilm
End Get
End Property
Public ReadOnly Property Genere() As Integer
Get
Return GenereFilm
End Get
End Property
Private Sub CaricaList()
Dim myFilms As New ArrayList
' Aggiungere le voci della struttura del reparto all'elenco matrice
With myFilms
.Add(New Film("Pippo", 1, "Fantasy"))
.Add(New Film("Pluto", 44, "Horror"))
.Add(New Film("Paperino", 283, "Commedia"))
.Add(New Film("Topolino", 66, "Azione"))
End With
' Eseguire l'associazione dell'elenco matrice alla casella combinata
With ListBox1
.DataSource = Nothing
.DataSource = myFilms
'le proprità pubbliche della classe sono quello che posso legare
.DisplayMember = "Name"
.ValueMember = "Id"
End With
End Sub
End Class
Ciao, alla prossima :-)
Solo chi fa sbaglia :-)