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
)?
views:
304answers:
1
+2
A:
You can iterate through DataRows in BindingSource to find selected one.
Jacob Seleznev
2009-09-03 04:16:45
Yeah - quite simply the simplest solution. Though I am surprised there is no easier way to sync two BindingSources that way
Noam Gal
2009-09-03 10:34:14