WinForm 2.0 无代码两个DataGridView实现Master/Details


private void OnFormLoad(object sender, EventArgs e)
{
// Get the data set with parent / child tables into a data set
CustomersDataSet customers = CustomersDataSet.GetCustomers();
// Set up the data sources normally for the first grid
m_CustomersBindingSource.DataSource = customers;
m_CustomersBindingSource.DataMember = "Customers";
m_CustomersGrid.DataSource = m_CustomersBindingSource;
// Set up the data sources for the child source to point to
// the parent source, and the contained relation
m_ChildOrdersBindingSource.DataSource = m_CustomersBindingSource;
m_ChildOrdersBindingSource.DataMember = "FK_Orders_Customers";
// Child grid to child connector
m_OrdersGrid.DataSource = m_ChildOrdersBindingSource;
// Navigator to parent connector
m_BindingNavigator.BindingSource = m_CustomersBindingSource;
}
posted @ 2007-11-25 21:43  曹振华  阅读(352)  评论(0编辑  收藏  举报