在datagrid视图中搜索字符串 [英] Searching string inside datagrid view
本文介绍了在datagrid视图中搜索字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的所有人,
如何在datagridview中搜索字符串?我有一个文本框和一个名为查找的按钮,我希望当用户键入一个单词或一个单词的一半时,所有具有这些字母的单词都应以高亮显示.
Dear All,
How to search strings inside the datagridview? I''ve a textbox and and a button named find, I want when the user type a word or half of a word all words having those letters should higlight in a coloumn???
推荐答案
您好,Naser
您必须为此使用SQL查询:-
Query ="Select * From TableName where ColumnName =''" + TextBox.Text +";
然后将此查询的结果填充到临时数据表DT_Temp中.
最后将您的DataGridView的DataSource设置为DT_Temp,如:
DataGridView.DataSource = DT_Temp;
希望这项工作
Hi Naser
You have to use SQL query for this :-
Query= "Select * From TableName Where ColumnName = ''"+TextBox.Text+"''";
Then Fill the Result of this Query in a tempory DataTable DT_Temp.
And at last set the DataSource of Your DataGridView as DT_Temp like :
DataGridView.DataSource=DT_Temp;
Hope This Work
如果您在应用程序中使用jQuery,则可以使用它.它将提供您搜索的动态外观.示例如下:
If you are using jQuery in your application then u can use it. It will provide the dynamic look of your search. The examples is below:
(< html_element_where_you_want_to_check>:contains(``您要搜索的文本'')").css("text-decoration","underline");
("<html_element_where_you_want_to_check>:contains(''Text you want to search'')").css("text-decoration", "underline");
这篇关于在datagrid视图中搜索字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文