3

I have a BindingSource bound to a DataTable.

I use the BS Filter and would like to iterate the filtered dataset of the DataTable using the Bindingsource.

I know I can do a MoveFirst and the MoveNext and each time using the BS.Position get the correct row in the underlying DataTable. But how do I know when the sets ends? I'm sure there must be such a property, but what is it?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Alex
  • 2,081
  • 14
  • 49
  • 76

2 Answers2

3
Private Sub BindDataGridView()    
    Dim count As Integer = 0
    For count = 0 To EmployeeListBindingSource.Count - 1
        Dim RowIndex As Integer = dataGrdView1.Rows.Add()
        Dim row As DataRowView = DirectCast(EmployeeListBindingSource.Item(count), DataRowView)
        dataGrdView1.Rows(RowIndex).Cells(0).Value = row.Item(1).ToString
        dataGrdView1.Rows(RowIndex).Cells(2).Value = row.Item(0).ToString
    Next
End Sub

Declare a row as:

Dim row As DataRowView = DirectCast(EmployeeListBindingSource.Item(count), DataRowView)

Then, access columns like:

row.Item(1).ToString

Compare it with if CompareStr <> row.Item(1).ToString then

I hope this helps.

A5C1D2H2I1M1N2O1R2T1
  • 190,393
  • 28
  • 405
  • 485
1

BindingSource has Count property

Anton Setiawan
  • 913
  • 10
  • 15