我正在尝试制作一个主详细信息表单,主记录绑定到一个绑定源,详细信息 datagridview 绑定到第二个绑定源
它工作得很好,只有childBindingSource.SupportSorting
属性是假的。
masterBindingSource.SupportsSorting
是真的。有没有办法让我childBindingSource
支持排序 - 假设它基于另一个支持排序的绑定源?
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;
}