Cannot sort DataGridView bound to array

  • Thread starter Thread starter StanB
  • Start date Start date
S

StanB

Should DataGridView sort work if the datasource is an array?

It works fine out of the box if bound to DataSet...
 
It is so nice that you published the reusable class!

I do get an error, though.

It fails somewhere within your delegate, don't know where, because debugger
doesn't step
into the class.

I only added a constructor to the class:

public SortableBindingList(IList<T> list)
: base(list)
{
}

so I can initialize it from my array.

That shouldn't cause the error, should it?
 
I had to change

List<T> itemsList = this.Items as List<T>;

to

List<T> itemsList = new List<T>(Items);

in order to fix that. Otherwise itesmList was null
 
StanB schreef:
It is so nice that you published the reusable class!

I do get an error, though.

It fails somewhere within your delegate, don't know where, because debugger
doesn't step
into the class.

I only added a constructor to the class:

public SortableBindingList(IList<T> list)
: base(list)
{
}

so I can initialize it from my array.


public SortableBindingList(IEnumerable<T> enumerable)
{
if (enumerable == null)
{
throw new ArgumentNullException("enumerable");
}

foreach (T t in enumerable)
{
this.Add(t);
}
}
 
Back
Top