Visual Basic: Find a record in a BindingSource and set the BindingSource's position to it

Platform:Visual Basic
Task:Find a record in a BindingSource and set the BindingSource's position to it
Discussion:
Sometimes you need to manually search for a record in a BindingSource and then move the BindingSource.Position property to it. Here is how.
Example:
            Dim MyBS As BindingSource = Me.Tbl_EventsBindingSource
            For i As Integer = 0 To MyBS.Count - 1
                Dim MyRowView As DataRowView = MyBS.Item(i)
                If MyRowView.Item("Event_ID") = "a6c26ffd-c792-432e-8f22-57ffc8b339c0" Then
                    MyBS.Position = i
                    Return
                End If
            Next
Back to Index