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 に答える