我正在使用 Search As You Type in C#,如此处所述http://www.codeproject.com/Articles/138595/Search-As-You-Type-in -C
如果基础表中的数据发生更改,则此方法可以正常工作,除非我刷新所有已完成多次搜索但可以找到更新绑定源的方法,否则它永远不会显示在数据网格中
//This method is fired by the KeyUp event handler on the textbox.
//The purpose of this method is to take the text from the search
//box, split it up into words, and then create and assign a filter
//statement that will do a LIKE comparison on each of the selected
//search fields. Each word's filter statement is AND'ed together
private void txtSearch_KeyUp(object sender, KeyEventArgs e)
{
string outputInfo = "";
string[] keyWords = txtSearch.Text.Split(' ');
foreach (string word in keyWords)
{
if (outputInfo.Length == 0)
{
outputInfo = "(Name LIKE '%" + word + "%' OR ProductModel LIKE '%" +
word + "%' OR Description LIKE '%" + word + "%')";
}
else
{
outputInfo += " AND (Name LIKE '%" + word + "%' OR ProductModel LIKE '%" +
word + "%' OR Description LIKE '%" + word + "%')";
}
}
//Applies the filter to the DataView
myView.RowFilter = outputInfo;
}