How to reset bindingsource filter to nothing

前端 未结 4 501
半阙折子戏
半阙折子戏 2021-01-24 12:55

Using BindingSource on LINQ to SQL, and having implemented a BindingList in my project, I have to use a Textbox to filter rows in a

4条回答
  •  遇见更好的自我
    2021-01-24 13:25

    Try it like this:

    if (textBox1.Text.Length == 0) {
      productBindingSource.RemoveFilter();
    } else {
      productBindingSource.Filter = "ProductName = '" + textBox1.Text +"'";
    }
    
    // productDataGridView.DataSource = productBindingSource;
    

    The DataGridView shouldn't need to be DataSourced again if it's already using productBindingSource.

提交回复
热议问题