I have a MSHFlexGird (fgdCompany) and a search command. When the user enters the search data into "txtSearch", the command should search for the data and show it to the user by :

 Highlighting the record in the MSHFlexGrid
 By bringing the row that contains the searched data to the top of the MSHFlexGrid.

The code that I am using is given below. The search function works perfectly. Only thing is I can't make the record that contains the searched data be highlighted so that the user knows in which record the data that was search data is present. Can anybody could give me the code to highlight the record found in any of the two methods given above (preferably the first option).

    Dim xString As String, xRow As Integer, xNext As Integer

    xString = txtSearch.Text
    For xNext = 0 To fgdCompany.Rows
    fgdCompany.Row = xNext
    xRow = fgdCompany.Row
    If xString = fgdCompany.TextMatrix(xRow, 1) Then 'Assuming that the string is in coloumn 1...
    myRow = fgdCompany.Row
    Exit For
    End If
    Next xNext
4 Years
Discussion Span
Last Post by Mamoundi

You can do highlighting by setting the CellBackColor property for each cell in the row. Here's a little code snippet that will steer you in the right direction:

Me.MSHFlexGrid1.Row = 10

For j = 0 To Me.MSHFlexGrid1.Cols - 1
    Me.MSHFlexGrid1.Col = j
    Me.MSHFlexGrid1.CellBackColor = vbGreen
Next j

Hope that helps! Good luck!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.