Here is an example of the class/collection:
Code:
Public Class CBarCode
Private nBarCodeNumber As Integer = 0
Private sBarCodeValue As String = ""
Private sBarCodeType As String = ""
Private nBarCodePage As Integer = 0
Private sIndexField As String = ""
End Class
Public Class CBarCodes
Inherits Dictionary(Of String, CBarCode)
End Class
I tried binding the collection directly, but got an error: "Complex DataBinding accepts as a data source either an IList or an IListSource". So I added a "BindingSource" object and used it.
Here is an example of the code:
Code:
lstBarCodes.BeginUpdate()
lstBarCodes.DataSource = CBarCodesBindingSource
CBarCodesBindingSource.DataSource = oBarCodes
'CBarCodesBindingSource.DataMember = "IDCSTProcess.CBarCode"
lstBarCodes.DisplayMember = "BarCodeValue"
'lstBarCodes.ValueMember = "BarCodeNumber"
lstBarCodes.EndUpdate()
lstBarCodes.Refresh()
With this code, I get one value in the list: [0, CBarCode]
If I uncomment the "DataMember" line, I get this error: "DataMember property 'CBarCode' cannot be found on the DataSource". If I uncomment the ValueMember line, I get "cannot bind to new value member. Parameter name: value".
It seems like it is trying to bind to the collection itself, rather than the members of the collection. This is where I think I am going wrong, and would like to see some examples of it being done.
Bookmarks