SortedBindingList and Interfaces

SortedBindingList and Interfaces

Old forum URL: forums.lhotka.net/forums/t/915.aspx


cwaldmann posted on Wednesday, August 16, 2006

I am having trouble creating a SortedBindingList for a list that inherits from BusinessListBase.  The items on the list are typed as an interface that inherits from iEditableBusinessObject.  So I end up with something like this

Child interface:
Public Interface IObject
Inherits Csla.Core.IEditableBusinessObject

Child object:
Public Class oObject
Inherits Csla.BusinessBase(Of oObject)
Implements IObject

List:
Public Class ObjectList
Inherits Csla.BusinessListBase(Of ObjectList, IObject)

When I try to create a SortedBindingList of the ObjectList using this code:

Dim lstObjects As New Csla.SortedBindingList(Of ObjectList)(_Parent.oObjects)

I receive:

"Unable to cast object of type 'ObjectList' to type 'System.Collections.Generic.IList`1[ObjectList]'."

Any idea how I can create a SortedBindingList within the framework of this object structure?

Thanks.

xal replied on Wednesday, August 16, 2006

The problem is that you're passing the type of the list instead of the item... It should look like this:

Dim lstObjects As New Csla.SortedBindingList(Of IObject)(_Parent.oObjects)


Andrés

cwaldmann replied on Wednesday, August 16, 2006

That did it! (I say, as I bop myself on the head)

Thanks.

Copyright (c) Marimer LLC