I have a DataRow, I need to get the RowIndex...

  • Thread starter Thread starter GaryB
  • Start date Start date
G

GaryB

Using FindRows I can get the array of DataRows that match my search
criteria. However I want to find out what rows these represent in the
overall DataTable. FindRows acts like a filter, but in my case, the
rows that are near the found rows (before or after) are significant to
the search. For example, if I FindRows matching
'TransactionNumber=12345', I would also be interested in seeing the
transactions that occurred around the same time. I can't find a way to
get from the DataRow collection back to their location within the main
DataTable. It seems CurrencyManager should help, but again, it's going
backwards from the usual implementation. Any ideas?
Thanks,
Gary B
 
Hi,

ds.Tables(0).DefaultView.Sort = "Column1"
Dim drFind() As DataRowView =
ds.Tables(0).DefaultView.FindRows("12")
Dim cm As CurrencyManager = CType(Me.BindingContext(ds.Tables(0)),
CurrencyManager)

For iRow As Integer = 0 To ds.Tables(0).Rows.Count - 1
If ds.Tables(0).Rows.Item(iRow).Equals(drFind(0).Row) Then
cm.Position = iRow
Exit For
End If
Next


Ken
 
Much Thanks Ken, the

ds.Tables(0).Rows.Item(iRow).Equals(drFind(0).Row)

was the missing link for me. I didn't know (or think to find) that there
was a way to check if DataRows were equivalent.
Thanks again,
gary b
 
Back
Top