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; }
转载于:https://www.cnblogs.com/czh-liyu/archive/2007/11/25/971990.html