我有一个带有 2 个网格的主明细表:客户 = 主控,订单 = 明细。从主网格中选择新客户时如何刷新详细信息?这是我的代码:
public partial class Form1 : Form
{
AutoLotEntities context = new AutoLotEntities();
BindingSource customerBindingSource;
BindingSource orderBindingSource;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
customerBindingSource = new BindingSource();
orderBindingSource = new BindingSource();
customerBindingSource.DataSource = context.Customers;
orderBindingSource.DataMember = "Orders";
orderBindingSource.DataSource = customerBindingSource.DataSource;
grdCustomers.DataSource = customerBindingSource;
grdOrders.DataSource = orderBindingSource;
}
}
我在 Form1.Desginer.cs 中的 IDE 生成代码的帮助下设法做到了这一点,但我想用非生成代码手动完成,看看这个东西是如何工作的。