BindingSource刷新

4
我有两个类,即CustomerOrderCustomer类,其中Customer类引用了一个订单集合。我使用主从BindingSource来绑定数据。
我的问题是当我使用懒加载模式来加载订单时,我的详细BindingSource没有更新。
用户界面(UI)。
BindingSource1.datasource = GetCustomers();
BindingSource2.DataMember = "Orders";
BindingSource2.datasource = BindingsSource1;

在我的datagridView1点击事件中:

if (customer.orders != null)
{
  customer.Orders = LoadOrders();
}

我很感激你能帮我处理这个问题。


这是.NET吗?听起来像WinForms,但请将其标记为此类。 - H H
你尝试重新分配它了吗? - ba__friend
你可能想查看这个链接:http://sandbox.vbcity.com/blogs/vbfeeds/archive/2008/12/10/master-details-with-entity-framework-explicit-load.aspx - ioWint
1个回答

9

尝试重新设置绑定:

BindingSource1.DataSource = GetCustomers();
BindingSource2.DataMember = "Orders";

BindingSource2.DataSource = BindingSource1;
BindingSource2.ResetBindings(true);

1
除非模式已更改,否则可以将false作为参数传递。 - Ray Goudie

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接