2012-06-30 66 views

回答

1

假設有這樣一個員工類:

Public Class Employee 
    Public Property ID As Integer 
    Public Property FirstText As String 
    Public Property SecondText As String 
    ' and go on with other properties 
    .... 
End Class 

現在,當您填充您的列表框,您的列表框的將DisplayMember和ValueMember設置爲員工

Dim myList As ArrayList = New ArrayList() 
myList.Add(New Employee() With {.ID = 1, .FirstText = "John Doe", .SecondText = "Doe John"}) 
myList.Add(New Employee() With {.ID = 2, .FirstText = "Mark Ross", .SecondText = "Ross Mark"}) 

ListBox1.DataSource = myList 
ListBox2.DataSource = myList 

ListBox1.ValueMember = "ID" 
ListBox1.DisplayMember = "FirstText" 

ListBox2.ValueMember = "ID" 
ListBox2.DisplayMember = "SecondText" 
兩種不同的屬性
相關問題