6
Reply

How to filter datagridview by making any change in the textbox

Samio

Samio

Jul 26 2012 11:10 AM
4.3k
Using Linq to sql through bindingsource control in WinForms, I could not get this to work:

private void textBox1_TextChanged(object sender, EventArgs e)
{
this.productBindingSource.Filter = string.Format("dataGridViewTextBoxColumn1 like '%{0}%'", textBox1.Text.Trim().Replace("'", "''"));
productDataGridView.DataSource = productBindingSource;
}
When I type some letter in the textbox nothing happens in the datagridview.
Thanks for advices ...


Answers (6)