我的Datagrid绑定到了一个DATASET,这个DataSet中包含了两个DataTable他们之间设置了主子关系。
程序中该如何判断Datagrid当前显示的是主表还是子表呢?

解决方案 »

  1.   

    Private Sub GetChildTable()
        Dim t As DataTable
        Dim dr As DataRelation
        ' Get a DataRelation of a DataSet.
        dr = DataSet1.Relations("CustomerOrders")
        ' Get the child DataTable of the relation.
        t = dr.ChildTable
        ' Print the name and number of rows of the child table.
        Debug.Write( t.TableName, t.Rows.Count.ToString())
     End SubDataRelation.ChildTable 属性 获取此关系的子表。
      

  2.   

    你可以通过DataGrid的Navigate事件来告知,详情参看msdn。