I have a datagridview with list of items in the column. I have a text box where i type a search string.
Currently i have implemented a method which is working in almost all scenarios except the following one
Suppose a list contains a 24hrs S Creatinine and S creatinine and when i type a creatinine
it searches first occurance of the string and highlights it.
My code for the same is as below.
Private Sub TextBox9_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox9.TextChanged
dgvOIList.ClearSelection()
dgvOIList.Sort(dgvOIList.Columns("Oiname"), System.ComponentModel.ListSortDirection.Ascending)
Dim rowindex As Long = GridRowLocator(dgvOIList, "Oiname", TextBox9.Text.ToUpper, "Text")
If rowindex = -1 Then Exit Sub
dgvOIList.Rows(rowindex).Selected = True
dgvOIList.FirstDisplayedScrollingRowIndex = rowindex
dgvOIList.CurrentCell = dgvOIList.Item("Oiname", CInt(rowindex))
dgvOIList.CurrentCell.Selected = True
End Sub
Public Function GridRowLocator(ByVal dtg As DataGridView, ByVal ColumnName As String, _
ByVal ValueToSearch As String, ByVal strSearchType As String) As Long
Dim CurrentRowIndex As Long = -1
Try
Select Case strSearchType.ToUpper
Case "TEXT"
If dtg.Rows.Count > 0 Then
For i = 0 To dtg.Rows.Count - 1
If
dtg.Rows(i).Cells(ColumnName).Value.ToString.Contains(ValueToSearch.ToUpper) = True Then
CurrentRowIndex = dtg.Rows(i).Index
Exit For
End If
Next
End If
End Select
Catch ex As Exception
MsgBox("Error: " & ex.Message, MsgBoxStyle.Information)
End Try
Return CurrentRowIndex
End Function
My requirement is all the list items containing the search string should be grouped together one below another. Can some expert pls advise on how to do this.
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/AutoComplete/AutoComplete.aspx