在DGV中突出显示文本,在文本框中匹配文本 [英] Highlight text in DGV matching text in textbox

查看:64
本文介绍了在DGV中突出显示文本,在文本框中匹配文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网上搜索了一下,但是找不到我想要的东西.我在文本框上有一个keyup脚本,该脚本可过滤数据库中的数据并加载datagridview.我只是想突出显示在与之匹配的任何单元格中找到的任何文本会很好 在文本框中键入的搜索字符串.只是一个想法

昏暗的PartColsSearch作为字符串="ID,图像,SerialPN,MYPN,CustomerPN,CustomerID,CustomerName,REV,描述," &
        附加费,PriceEA,PriceBreak,DateModified,UpdatedBy,注释"
        使用mysqlconn作为新的MySqlConnection(My.Settings.MySQLconn)
            将PartsDA用作新的MySqlDataAdapter(从tgt.parts中选择& PartColsSearch&",其中mypn类似于%"&
            tb_search.Text& %"或%"这样的客户名称; & tb_search.Text& "%"或类似'%"的说明; & tb_search.Text&
            "SerialPN Asc的%"顺序",mysqlconn)
                将Dim PartsCB用作新的MySqlCommandBuilder(PartsDA)
                PartsTable.Clear()
                PartsDA.Fill(PartsTable)
                PartsBS.DataSource =零件表

                与dgv_parts

                结束于
                零件CB =无
            最终使用
        最终使用


生活就好像你今天要死一样,学习就好像你要永远生活-大雄甘地

解决方案

你好,

如果您没有告诉我们您找到了什么,或者不满意,我们可能会建议相同的解决方案,因此请告诉我们您尝试过和不喜欢的事情.


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

解决方案

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.


这篇关于在DGV中突出显示文本,在文本框中匹配文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆