
Originally Posted by
lechip
What if I what to view the PARENT of an actual record?
This data-binding technique is about filtering child records. There's nothing built in that I aware of that will display or select a parent record based on selection of a child.
It's not too hard to do with a small amount of code though. Once you've got a child DataRow, you can call its GetParentRow method to get the parent DataRow. Assuming that you have two BindingSources bound to two DataTables with a DataRelation between them, that might look like this:
vb.net Code:
Private Sub childBindingSource_CurrentChanged(sender As Object, e As EventArgs) Handles childBindingSource.CurrentChanged
Dim childRow As DataRow = DirectCast(Me.childBindingSource.Current, DataRowView).Row
Dim parentRow As DataRow = childRow.GetParentRow("ParentChildRelation")
Dim parentIndex As Integer = Me.parentBindingSource.Find("ParentID", parentRow("ParentID"))
Me.parentBindingSource.Position = parentIndex
End Sub