如何在数据网格视图中过滤记录并在数据网格中显示所选记录
问题描述:
请我有一个带有事务绑定源的数据网格视图,当我在文本框中输入一个值并单击按钮排序时,我希望数据网格仅显示已排序的行而不是所有记录.谢谢
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
答
你必须把这样的代码放在你的控件中:
You have to put code like this in your control :
YourGridViewBindingSource.Filter = String.Format("YourDBColumn Like ;'*" & FilterValue) & "*'"
例如,您可以将代码用作 TextBox.textchanged
控件,以便在您在 TextBox 中键入内容时过滤 Datagrid 视图
for example you can use the code as your TextBox.textchanged
control to filter the Datagrid view as you type in the TextBox