Click here to Skip to main content
15,899,313 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I search single row from gridview using vb.net code?
Posted
Comments
Lalit PB 2-Apr-12 6:27am    
on what criteria you want to search your row?

one solution is to iterate your rows and based on condition for particular row perform your processing.

1 solution

What specifically are you having trouble with? Grabbing the row you want? Or checking each cell in that row? What are you searching for?

To check each cell in the row, you will want to loop through the grid's columns. You can do that like this:

VB
'In my example, I have a column in my grid called id.  I'm only grabbing rows that have a id that matches my variable strRowIdToSelect
For Each dgvr as DataGridViewRow in myDataGrid.Select("id=" & strRowIdToSelect)
   For Each dgvc as DataGridViewColumn In myDataGrid.Columns
      'The value I'm searching for is stored in a a variable called strValueToSearchFor
      If dgvr.Cells(dgvc.Index).Value = strValueToSearchFor Then
         'Found the value
         'Add code to do what you want after you've found it
      End
   Next
Next
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900