Inherited Bindinglists

link664

Member
Joined
Nov 13, 2007
Messages
6
Programming Experience
5-10
Hi guys,

I have two classes, clsA and clsB, which both inherit clsLetter. clsLetter contains a bindinglist that will contain either clsA or clsB objects.

I want to be able to declare this list as bindinglist(of clsLetter) at design time and then at run time assign that bindinglist a new bindinglist(of clsA/ clsB).

Now i know that I can use the Ibindinglist interface in the declaration but this provides me with other issues in displaying data (it will only show the properties of clsLetter, not of clsA or clsB).

Is there a way to do this? Why is it that bindinglists don't see inherited types?

Thanks,
Dane.
 
Now i know that I can use the Ibindinglist interface in the declaration but this provides me with other issues in displaying data (it will only show the properties of clsLetter, not of clsA or clsB).
If you declare the bindinglist as IBindingList you can assign it a new BindingList(Of T) where T can be any type. "It" will show the type you have chosen, and the properties of this class including those it has inherited. For example you have one property in each class, L in clsLetter, A in clsA, B in clsB. If you assign a BindingList(Of clsA) and bind it to a DataGridView it will generate columns for L and A.
 
Back
Top