Reputation: 83
I'm using a textbox to search a datagridview. But it only searches one column. I'd like to use it to search other columns as well. The code i'm currently using for the searchbar is:
private void autoZoeken_txt_TextChanged(object sender, EventArgs e)
{
DataView DV = new DataView(dbdataset);
DV.RowFilter = string.Format("kenteken LIKE '%{0}%'", autoZoeken_txt.Text);
autoView_dgv.DataSource = DV;
}
Upvotes: 1
Views: 1281
Reputation: 67898
You just need to modify the code to leverage the OR
:
private void autoZoeken_txt_TextChanged(object sender, EventArgs e)
{
DataView DV = new DataView(dbdataset);
DV.RowFilter = string.Format(
"kenteken LIKE '%{0}%' OR field2 LIKE '%{0}%'", autoZoeken_txt.Text);
autoView_dgv.DataSource = DV;
}
and so on.
Upvotes: 5