vb.net 如何在数据网格视图中过滤记录并在数据网格中显示所选记录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7786556/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 15:44:22  来源:igfitidea点击:

How to filter records in datagrid view and show the selected record in the datagrid

vb.net

提问by Bakare

Please I have a datagridview with transaction bindingsource I want the datagrid to show the sorted rows only not all the records when i enter a value into a textbox and click button sort. thanks

请我有一个带有事务 bindingsource 的 datagridview 我希望当我在文本框中输入一个值并单击按钮排序时,datagrid 只显示排序的行而不是所有记录。谢谢

采纳答案by Prooshani

You have to put code like this in your control :

你必须把这样的代码放在你的控件中:

 YourGridViewBindingSource.Filter = String.Format("YourDBColumn Like ;'*" & FilterValue) & "*'"

for example you can use the code as your TextBox.textchangedcontrol to filter the Datagrid view as you type in the TextBox

例如,您可以使用代码作为您TextBox.textchanged在 TextBox 中键入内容时过滤 Datagrid 视图的控件