如何使用c#.net windows应用程序中的文本框文本过滤datagridview? [英] How to filter datagridview using textbox text in c# .net windows application?

查看:73
本文介绍了如何使用c#.net windows应用程序中的文本框文本过滤datagridview?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我使用此代码过滤datagridview,它正在过滤但此搜索字符的空行显示。

< pre lang =cs> var dataTable =(DataTable)dgvDisplayTiles.DataSource;
var dataView = dataTable.DefaultView;
dataView.RowFilter = string .Format( FloorTileName如'{0}%',txtSearchByName.Text);





请帮帮我,我们怎么样根据搜索字符显示填充datagridview行。



在此先感谢。



Ankit Agarwal
软件工程师

解决方案

在设置rowfilter之后写入dgvDisplayTiles.DataBind()。


Hi






你的过滤器很好..



过滤后,将DataView分配给网格而不是Datatable。

 dgvDisplayTiles.DataSource = dataView; 





可以安全地修剪任何不需要的空格的文本框中的值。



 txtSearchByName.Text.Trim(); 


Hello,

I am using this code for filtering datagridview, it's filtering but blank row display of this search character.

var dataTable = (DataTable)dgvDisplayTiles.DataSource;
                var dataView = dataTable.DefaultView;
                dataView.RowFilter = string.Format("FloorTileName like '{0}%'", txtSearchByName.Text);



please help me, How can we display filling datagridview row according to search character.

Thanks in Advance.

Ankit Agarwal
Software Engineer

解决方案

write dgvDisplayTiles.DataBind() after the setting the rowfilter.


Hi


your filter is fine..

after filtering, assign the DataView to the grid not the Datatable.

dgvDisplayTiles.DataSource =  dataView;



Its safe to Trim the value from text box for any unwanted empty spaces.

txtSearchByName.Text.Trim();


这篇关于如何使用c#.net windows应用程序中的文本框文本过滤datagridview?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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