Making a type-ssafe collection class bindable..?

Merrion

Junior Contributor
Joined
Sep 29, 2001
Messages
265
Location
Dublin, Ireland
I have a usercontrol and one of it's members is a type safe collection (inherited from CollectionBase.DictionaryBase).

Now I want this collection to be bindable (read-only) to a datagrid. I have added the attribute <Bindable()> to the property and implemented IListSource in the control and returned this list from GetList() overloaded function but it doesn't show up in the datagrid's bindings.

What step(s) am I missing?

Thanks in advance,
Duncan
 
OK - I was on the wrong track with IListSource - It should have been IBindableList...now the Datagrid binds to the list but it doesn't know anything about the data type within the collection - how do I do that part?
 
Implement the Add Sub, Create Method, and Item Property with you're datatype in mind. So, for the Item property, you'll do something like this:
Visual Basic:
Default Property Item(ByVal key As String) As MySpecificDataType
  Get
      Return CType(Dictionary.Item(key), MySpecificDataType)
  End Get
  Set(ByVal Value as MySpecificDataType)
      Dictionary.Item(key) = Value
   End Set
End Property
 
Back
Top