【发布时间】:2013-04-19 16:04:25
【问题描述】:
我有一个包含 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 生成代码的帮助下设法做到了,但我想用非生成代码手动完成,看看这个东西是如何工作的。
【问题讨论】:
标签: c# winforms entity-framework