I have rowfilter from textbox input and here is how it looks like
var dt = (DataTable)dataGridView1.DataSource;
try
{
dt.DefaultView.RowFilter = string.Format("KATBR like '%{0}%'", filterKatbr.Text.Trim().Replace("'", "''")) + "AND " + string.Format("NAZIV like '%{0}%'", filterNaziv.Text.Trim().Replace("'", "''"));
dataGridView1.Refresh();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
It supports 2 textbox and filter from 2 textbox in same time but for now lets focus on one textbox. What i want to achieve is if i type in textbox something like this Computer%Land
, it needs to filter me everything that must have Computer
then any characterS between and then must have Land
after it.
It doesn't matter what character is used for that anything between
. I used %
but it can be anything.
So if i had table like this:
|Computer432Land |
|Computer321 Land |
|Land 213 Computer |
|Computer asd13 Land|
Result would be first, second and fourth column.
Don't think of your filter as a single statement, but instead as two statements to be joined. That is, you need everything that:
Like so:
As shown below, using your example data++ we see the expected results.