Reputation: 3405
I have a form with a DataGridView
that opens a details form on a double click.
When opening the second form I set it to use the same DataSet
instance as the parent form. i now want to make sure the second form is pointing at the same DataRow
as the parent as well.
At first I just sent in the Position
property of the parent form's BindingSource
, and set the same property on the BindingSource
of the details form. This worked just fine until I started sorting the DataGridView
- now the parent's position is showing the sorted value, and all hell breaks loose.
I then tried sending in the actual DataRow
and even the DataRowView
object of the parent BindingSource
, and using the Find
method on the details BindingSource
- but they all just return -1.
What other way I can use to set the BindingSource
Current
property, if I can't relay on indexes or on values? Do I have to use the Filter
method and construct a filter query dynamically (I have multiple properties for PK, so I can't just use Find
)?
Upvotes: 1
Views: 1226
Reputation: 8151
You can iterate through DataRows in BindingSource to find selected one.
Upvotes: 2