1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| Public Class UserControl1
Private _MaListe As New List(Of Personne)
Private _SelElement As Personne
Public Property MaListe As List(Of Personne)
Get
Return _MaListe
End Get
Set(ByVal value As List(Of Personne))
_MaListe = value
ComboBox1.DisplayMember = "Nom"
ComboBox1.ValueMember = "Id"
ComboBox1.DataSource = _MaListe
End Set
End Property
Public Property SelElement As Personne
Get
Return _SelElement
End Get
Set(ByVal value As Personne)
End Set
End Property
Private Sub ComboBox1_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedValueChanged
_SelElement = ComboBox1.SelectedItem
End Sub
End Class
<Serializable()> Public Class Personne
Public Property Id As Integer
Public Property Nom As String
Sub New()
End Sub
Sub New(ByVal I As Integer, ByVal N As String)
Id = I
Nom = N
End Sub
End Class |