使用BindingSource
到SQL,並且已經在我的項目實施BindingList
,我必須使用Textbox
在DataGridView
過濾行,所以當我刪除文本框的內容,過濾器應重置爲無。如何在LINQ重置BindingSource的過濾器,以什麼
我的代碼如下:
if (textBox1.Text.Length == 0)
{
productBindingSource.Filter = null;
}
else
{
productBindingSource.Filter = "ProductName = '" + textBox1.Text +"'";
//productBindingSource.RemoveFilter();
}
productDataGridView.DataSource = productBindingSource;
不過這並沒有什麼,什麼想法嗎?
這不起作用,您的鏈接爲數據集類型數據源提供代碼。請看看我最初的問題更新。 – 2012-08-01 21:10:41
如果做這個'productBindingSource.Filter =「」;' – wterbeek 2012-08-02 06:18:47
什麼發生沒有,因爲Filter不直接爲bindingSource控件工作,所以有必要在項目中實現一個BindingList並使用IEnumerable達到這個目的,請[看看這個](http://stackoverflow.com/questions/11691797/how-do-i-position-a-datagridview-to-the-searched-text-input/11701585#11701585)知道如何實現一個BindingList在你的項目中。 – 2012-08-02 14:00:31