简体   繁体   English

如何在DevExpress Winform中像主从细节一样将两个网格相互绑定

[英]How to bind two grid each other like master-detail represent in DevExpress Winform

I am wondering that how to bind two grid each other like master detail represent? 我想知道如何像主要细节一样将两个网格相互绑定? For example; 例如; I have two grid. 我有两个网格。 Orders and Order detail. 订单和订单明细。 Order detail is placed next of the Orders. 订单详细信息位于订单旁边。 I want to make a dynamic filter that can make rows hide or visible in detail table grid according to my selection.. This actions can be triggered by row select or row double click event. 我想制作一个动态筛选器,该筛选器可以根据我的选择使行在详细信息表格网格中隐藏或可见。此操作可以由行选择或行双击事件触发。 It does not matter. 不要紧。 I hope, I could tell properly. 希望我能说正确。 Thanks in advance. 提前致谢。

If you are using an ADO.NET dataset ( System.Data.DataSet ), the GridControl instance intended for displaying the detail data should be bound to an ADO.NET data relation. 如果使用的是ADO.NET数据集( System.Data.DataSet ),则用于显示详细数据的GridControl实例应绑定到ADO.NET数据关系。

Below is code snippet for binding of the standard NorthWind dataset in the two-grid master-detail manner: 以下是用于以两网格主从方式绑定标准NorthWind数据集的代码段:

BindingSource masterBS = new BindingSource();
masterBS.DataMember = "Orders";
masterBS.DataSource = nwindDataSet1;

BindingSource detailBS = new BindingSource();
detailBS.DataMember = "OrdersOrder Details";
detailBS.DataSource = masterBS;


this.gridControl1.DataSource = masterBS;
this.gridControl1.ShowOnlyPredefinedDetails = true; // 

this.gridControl2.DataSource = detailBS;

To see the complete code review the following DevExpress KB-article: How to Display Master-Detail Tables in Separate Grid Controls 要查看完整的代码,请查看以下DevExpress KB文章: 如何在单独的网格控件中显示主从表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM