4

I am trying to make a master-details form, with the master records bound to one binding source, and the details datagridview bound to a second binding source

It works pretty well, only the childBindingSource.SupportSorting property is false. masterBindingSource.SupportsSorting is true. Is there a way I can get the childBindingSource to support sorting - given that it is based on another binding source that does support sorting?

masterBindingSource.DataSource = GetBindingSource()   // .SupportsSorting = true
childBindingSource.DataSource = masterBindingSource   // .SupportsSorting = false
childBinding.DataMember = ChildItems

private BindingSource GetBindingSource()
{
   DbSet<ContactEvent> dset = Db.ContactEvents;
   IOrderedQueryable<ContactEvent> qry = dset.Where(p => p.Id > 0).OrderBy(x => x.Id);
   qry.Load();

   BindingList<ContactEvent> bindinglist = dset.Local.ToBindingList();
   var bindingSource = new BindingSource();
   bindingSource.DataSource = bindinglist;
   return bindingSource;
}
Kirsten
  • 15,730
  • 41
  • 179
  • 318
  • This is Windows Forms, right? – Gert Arnold Jan 22 '13 at 18:23
  • Yes - oops, i meant to tag it as such - have done now. – Kirsten Jan 22 '13 at 22:04
  • 1
    I know as much that [`BindingSource.SupportsSorting`](http://msdn.microsoft.com/en-us/library/system.windows.forms.bindingsource.supportssorting.aspx) is a read-only property: _true if the data source is an IBindingList and supports sorting; otherwise, false._ Further, setting DataMember resests the inner list of a binding source, apparently into a list not meeting these two conditions. But I fail to know what to do about it. Maybe you're lucky and a WinForms whiz like Hans Passant will bump into your question. – Gert Arnold Jan 22 '13 at 23:43

1 Answers1

1

With some help we got this working using this link at codeplex

I had to change my class to use the SortableBindingList instead of BindingList. It was interesting to me that BindingList alone was good enough for a grid at the master level - but not for a grid containing details.

Kirsten
  • 15,730
  • 41
  • 179
  • 318