Search Record in Grid Using Vb.Net Code

Search Record in Grid Using Vb.Net Code

 If intOldcnt <= IntTblCount - 1 Then  
 dgMain.UnSelect(intOldcnt)  
 End If  
 Dim inti As Integer  
 If strToSearch.Trim <> "" Then  
 For inti = 0 To IntTblCount - 1  
 If Convert.ToString(dgMain.Item(inti, 0)).Trim.ToUpper Like strToSearch.Trim.ToUpper & "*" Then  
 If blnFlag = True Then  
 dgMain.Select(inti)  
 IntCount += 1  
 End If  
 dgMain.CurrentRowIndex = inti  
 intOldcnt = inti  
 txtSearch.Focus()  
 Exit For  
 End If  
 Next  
 End If