none
Highlight text in DGV matching text in textbox RRS feed

  • Question

  • I've searched around the web a bit but cant find exactly what I'd like. I have a keyup script on a textbox that filters data from a database and loads a datagridview. I was just thinking it would be nice to highlight any text found in any cell that matched the search string typed in the textbox. Just a thought

     Dim PartColsSearch As String = "ID, Image, SerialPN, MYPN, CustomerPN, CustomerID, CustomerName, REV, Description, " &
            "Surcharge, PriceEA, PriceBreak, DateModified, UpdatedBy, Notes"
            Using mysqlconn As New MySqlConnection(My.Settings.MySQLconn)
                Using PartsDA As New MySqlDataAdapter("select " & PartColsSearch & " from tgt.parts where mypn like '%" &
                tb_search.Text & "%' OR customerpn like '%" & tb_search.Text & "%' Or Description Like '%" & tb_search.Text &
                "%' order by SerialPN Asc", mysqlconn)
                    Dim PartsCB As New MySqlCommandBuilder(PartsDA)
                    PartsTable.Clear()
                    PartsDA.Fill(PartsTable)
                    PartsBS.DataSource = PartsTable
    
                    With dgv_parts
    
                    End With
                    PartsCB = Nothing
                End Using
            End Using


    Live as if you were going to die today, learn as if you were going to live forever -Mahatma Gandhi

    Monday, February 20, 2017 9:06 PM

All replies

  • Hello,

    Without you telling us what you have found and don't like we may suggestion the same solution so please tell us what you have tried and didn't like.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Monday, February 20, 2017 10:09 PM
    Moderator
  • GT,

    Not cheap but these folks have it done well:

    https://www.youtube.com/watch?v=xr6gr7HaCrQ&list=PL8h4jt35t1wgb1MF4h-pWyaEgWj8JfoLD


    "One who has no vices also has no virtues..."

    Monday, February 20, 2017 10:20 PM
  • Frank, that is awesome. Really wish the MS DGV was 1/2 this functional.

    Live as if you were going to die today, learn as if you were going to live forever -Mahatma Gandhi

    Monday, February 20, 2017 11:08 PM
  • Frank, that is awesome. Really wish the MS DGV was 1/2 this functional.

    Live as if you were going to die today, learn as if you were going to live forever -Mahatma Gandhi

    Agreed!

    ;-)


    "One who has no vices also has no virtues..."

    Monday, February 20, 2017 11:10 PM