Samio

Samio

  • NA
  • 201
  • 175.4k

How to filter datagridview by making any change in the textbox

Jul 26 2012 11:10 AM
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)