主窗体一个bindingNavigator1 ,一个DATAGRIDVIEW ,BindingSource 和一个DATASET
子窗体一些TEXTBOX,BindingSource 和一个DATASET主子表DATASET一样。
子表的TEXTBOX绑定BindingSource 的一些字段。
如何通过主表的bindingNavigator1 导航下一个同步子表的数据。
Form2 f = new Form2();
//f.p_BindingSource = this.bindingSource ;
f.p_BindingSource.DataSource = this.bindingSource.DataSource;
f.p_BindingSource.DataMember = this.bindingSource.DataMember ;
f.Show();
这样写不能同步不知道是为什么???
子窗体一些TEXTBOX,BindingSource 和一个DATASET主子表DATASET一样。
子表的TEXTBOX绑定BindingSource 的一些字段。
如何通过主表的bindingNavigator1 导航下一个同步子表的数据。
Form2 f = new Form2();
//f.p_BindingSource = this.bindingSource ;
f.p_BindingSource.DataSource = this.bindingSource.DataSource;
f.p_BindingSource.DataMember = this.bindingSource.DataMember ;
f.Show();
这样写不能同步不知道是为什么???
Form2中只要TextBox,并在Form2创建的时候把BindingSource2传过去即可。Form2 f = new Form2(BindingSource2);
f.Show(); 这样就可以做到同步。
//f.p_BindingSource = this.bindingSource ;只是不知道我这样做绑定有啥错误。
怎么不能同步呢。
所以子的BindingSource的DataSource不能再设为DataSet,而是要把子的BindingSource.DataSource设置为主BindingSource,并且把子的BindingSource.DataMember设置为Relation