3

我有一个绑定到 DataTable 的 BindingSource。

我使用 BS 过滤器,并希望使用 Bindingsource 迭代 DataTable 的过滤数据集。

我知道我可以执行 MoveFirst 和 MoveNext,并且每次使用 BS.Position 都可以在基础 DataTable 中获取正确的行。但是我怎么知道集合什么时候结束呢?我敢肯定一定有这样的财产,但它是什么?

4

2 回答 2

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

将一行声明为:

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

然后,访问如下列:

row.Item(1).ToString

将其与 if CompareStr <> row.Item(1).ToString then

我希望这有帮助。

于 2012-05-18T11:07:26.943 回答
1

BindingSource 具有 Count 属性

于 2010-01-31T06:35:43.353 回答