I have a dictionary oject I created and I want to bind a listbox to it. I
am including the code for the dictionary object.
Here is the error I am getting:
"System.Exception: Complex DataBinding accepts as a data source either an
IList or an IListSource
at System.Windows.Forms.ListControl.set_DataSource(Ob ject value)
at USBSecure.frmUSBSecure.ExchangeInputAndOutputRepor ts() in
d:\usbsecure\USBSecure\frmUSBSecure.vb:line 743"
I tried to implement the IList interface and got the following:
'USBSecure.FOBS' must implement 'Overridable Function IndexOf(value As
Object) As Integer' for interface 'System.Collections.IList'.
So I try to override it and get an error that I can't do this because it is
not overriding a sub in the base class. All I want is to bind my listbox to
my dictionary. Any help is appreciated.
John
FOB Dictionary CODE:
Imports System.Collections
Public Class FOB
Public Enum FOBStatus
Enabled = 1
Disabled = 2
Validated = 3
Invalid = 4
End Enum
Private strFOBID As String
Private intFOBStatus As Integer
#Region "Constructors"
Public Sub New(ByVal strFOBNumber As String, ByVal intFOBStat As Integer)
strFOBID = strFOBNumber
intFOBStatus = intFOBStat
End Sub
Public Sub New()
End Sub
#End Region
#Region "Properties"
Public Property FOBID() As String
Get
Return strFOBID
End Get
Set(ByVal Value As String)
strFOBID = Value
End Set
End Property
Public Property Status() As Integer
Get
Return intFOBStatus
End Get
Set(ByVal Value As Integer)
intFOBStatus = Value
End Set
End Property
#End Region
End Class
Public Class FOBS
Inherits DictionaryBase
#Region "Public Methods"
Public Sub add(ByVal KeyFOB As FOB)
MyBase.Dictionary.Add(KeyFOB.FOBID, KeyFOB)
End Sub
Public Sub add(ByVal KeyFOB As String, ByVal FOBStatus As Integer)
MyBase.Dictionary.Add(KeyFOB, New FOB(KeyFOB, FOBStatus))
End Sub
Public Sub Remove(ByVal FOBID As String)
MyBase.Dictionary.Remove(FOBID)
End Sub
Public Sub Remove(ByVal KeyFOB As FOB)
MyBase.Dictionary.Remove(KeyFOB.FOBID)
End Sub
Public Function Contains(ByVal Keyfob As FOB) As Boolean
Return MyBase.Dictionary.Contains(Keyfob.FOBID)
End Function
Public Function Contains(ByVal KeyFOB As String) As Boolean
Return MyBase.Dictionary.Contains(KeyFOB)
End Function
#End Region
#Region "Properties"
Default Public Property FOB(ByVal KeyFOB As String) As FOB
Get
Return MyBase.Dictionary.Item(KeyFOB)
End Get
Set(ByVal Value As FOB)
MyBase.Dictionary.Item(KeyFOB) = Value
End Set
End Property
#End Region
Protected Overrides Sub finalize()
MyBase.Finalize()
End Sub
End Class