all groups > dotnet windows forms databinding > october 2005 >
You're in the

dotnet windows forms databinding

group:

BuildSortString exception


BuildSortString exception JohnC
10/18/2005 1:34:04 PM
dotnet windows forms databinding:
I am using the SortableBindingList<T> class described in the MSDN Custom Data
Binding article at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnforms/html/winforms11162004.asp?frame=true

This business object is displayed in a listbox using databinding via a
BindingSource oject. When I set the Sort property on my BindingSource object
and then modify the underlying data I get an exception from the
BindingSource's BuildSortString. This same exception was documented on the
microsoft forums at
http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=76499 without a
resolution. Is this a bug in .NET 2.0 or is there some other problem?

Thanks,
John
Re: BuildSortString exception JohnC
10/18/2005 5:34:02 PM
That was it, thanks!

[quoted text, click to view]
Re: BuildSortString exception Bart Mermuys
10/19/2005 12:00:00 AM
Hi,

[quoted text, click to view]

I think it is caused by some missing overrides in SortableBindingList<T> :

* Add two fields:
private PropertyDescriptor _sortProp = null;
private ListSortDirection _sortDir = ListSortDirection.Ascending;

* Add code inside ApplySortCore:
after "_isSorted=true" put :
_sortProp = property
_sortDir = direction

after "_isSorted=false" put:
_sortProp = null

* Add two more overrides:
protected override PropertyDescriptor SortPropertyCore
{
get { return _sortProp; }
}

protected override ListSortDirection SortDirectionCore
{
get { return _sortDir; }
}



HTH,
Greetings



[quoted text, click to view]

AddThis Social Bookmark Button