Datagridview C#中的模式匹配 [英] Pattern matching in Datagridview c#

查看:79
本文介绍了Datagridview C#中的模式匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Winform应用程序中使用C#在Datagridview中使用模式匹配来过滤值.

例如:
我有一个文本框和一个Datagridview,该网格包含三个值,例如X,Y,Z.如果我在文本框中输入Z,则网格仅显示Z.

帮助请..

预先感谢...

How to Filtering the values using pattern matching in Datagridview using C# in an winform application.

For Example:
I have one textbox and one Datagridview that grid contains three values like X,Y,Z .if i enter Z on the textbox the grid shows only Z.

Help pls..

Thanks in advance...

推荐答案

做到这一点的最佳方法是过滤绑定到datagridview的数据.假设您的DataGridView中填充了字符串列表,则可以使用LinQ仅选择包含"Y"的字符串,然后将datagridview重新绑定到过滤的选择.
The best way to do this is to filter your data that is being bound to the datagridview. Say if your DataGridView is populated with a list of strings, then you could use LinQ to select only the strings containing ''Y'' and the rebind the datagridview to the filtered selection.


这篇关于Datagridview C#中的模式匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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