主窗体一个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();
这样写不能同步不知道是为什么???

解决方案 »

  1.   

    Form1中,有DataSet1(A表和B表,A为主表,B为从表,同时他们直接有Relation关系名字为A_B),BindingSource1(DataSource属性为DataSet1,DataMember为A),BindingSource2(DataSource属性为BindingSource1,DataMember为A_B)
    Form2中只要TextBox,并在Form2创建的时候把BindingSource2传过去即可。Form2 f = new Form2(BindingSource2); 
    f.Show(); 这样就可以做到同步。
      

  2.   

    http://msdn.microsoft.com/en-us/library/2wcswths.aspx
      

  3.   

    三四数说的不错。
           //f.p_BindingSource = this.bindingSource ;只是不知道我这样做绑定有啥错误。
    怎么不能同步呢。
      

  4.   

    因为你的两个BindingSource没有通过Relation把他们关联起来。
    所以子的BindingSource的DataSource不能再设为DataSet,而是要把子的BindingSource.DataSource设置为主BindingSource,并且把子的BindingSource.DataMember设置为Relation