
Originally Posted by
kaliman79912
Hi again
Code:
For Each myRow As DataGridViewRow In dgvDisbursements.Rows
For Each myCell in myRow.Cells
'Do the search in myCell
Next
Next
I did not explicitly declare the type of myCell as it will be DataGridViewTextBoxCell or DataGridViewCheckBoxCell
thanks kaliman79912. It took me awhile to get it to work.
My code:
Code:
Private Function FindItems(ByVal strSearchString As String) As Boolean
dgvDisbursements.SelectionMode = DataGridViewSelectionMode.FullRowSelect
dgvDisbursements.ClearSelection()
Dim intCount As Integer = 0
Dim intCell As Integer
For Each myRow As DataGridViewRow In dgvDisbursements.Rows
For Each myCell In myRow.Cells
For intCell = 1 To 8
'Do the search in myCell
If InStr(1, dgvDisbursements.Rows(intCount).Cells(intCell).Value.ToString, strSearchString, CompareMethod.Text) Then
dgvDisbursements.Rows(intCount).Selected = True
FindItems = True
Exit Function
End If
Next
intCell += 1
Next
intCount += 1
Next
Return False
End Function