| Platform: | Visual Basic |
| Task: | Find a record in a BindingSource and move to it |
| Discussion: | You need to locate a record in a BindingSource and move the BindingSource.Position property to it. Note: While this Sub will move the position of the BindingSource in question it will not move any parent BindingSources. You have to do that manually. |
| Example: | Private Sub FindRecordInBindingSourceAndMoveToIt(ByVal BindingSource As BindingSource, ByVal ColumnName As String, ByVal Value As String)
For i As Integer = 0 To BindingSource.Count - 1
Dim MyRowView As DataRowView = BindingSource.Item(i)
If MyRowView.Item(ColumnName) = Value Then
BindingSource.Position = i
Return
End If
Next
End Sub |