Help! - How to declare Property of type FilteredBindingList

Help! - How to declare Property of type FilteredBindingList

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


andrewrajcoomar posted on Thursday, January 15, 2009

How do I create a property of type FilteredBindingList in a base form, so that inherited forms can reference and set that property?

Sorry, I know this is not very specific to CSLA.

Thanks,

Andrew

RockfordLhotka replied on Thursday, January 15, 2009

That may be a little tricky, because Windows Forms doesn't like generics very much, and FilteredBindingList is a generic type.

private FilteredBindingList<????> _myProperty;
public FilteredBindingList<????> MyProperty
{
  get { return _myProperty; }
  set { _myProperty = value; }
}

Obviously the trick is the "???". Normally this would be something like T, where T is a generic type provided to the containing class. But you can't make a Form generic or Windows Forms will have trouble.

So you'll probably need to use the non-generic IBindingList interface:

private IBindingList _myProperty;
public IBindingList MyProperty
{
  get { return _myProperty; }
  set { _myProperty = value; }
}

And then cast the property value to something more specific when you want to use it.

andrewrajcoomar replied on Thursday, January 15, 2009

Rocky,

Thank you sir, that worked. My next issue is how to use the non-generic IReadOnlyObject for ChartFieldInfo so that:

Dim filteredList As New Csla.FilteredBindingList(Of ChartFieldInfo)(_BOReadOnlyList)

becomes

Dim filteredList As New Csla.FilteredBindingList(Of BOReadOnlyInfo)(_BOReadOnlyList)

I tried this unsuccessfully:

Private _BOReadOnlyInfo As Csla.Core.IReadOnlyObject

Protected Property BOReadOnlyInfo() As Csla.Core.IReadOnlyObject

Get

Return _BOReadOnlyInfo

End Get

Set(ByVal value As Csla.Core.IReadOnlyObject)

_BOReadOnlyInfo = value

End Set

End Property

 

By the way, in the above:

Private _BOReadOnlyList As Csla.Core.IReadOnlyCollection

works.

 

Thanks a million.

Andrew

Copyright (c) Marimer LLC