You can easily search the datagridview using a textbox while typing the search words. Try the below simple example. It works perfectly with me.
DataTable dt = new DataTable();
DataView dv = null;
private void Test()
{
dt.Columns.Add("id", typeof(Int32));
dt.Columns.Add("code", typeof(String));
DataRow dr;
dr = dt.NewRow();
dr[0] = 1;
dr[1] = "abc";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = 2;
dr[1] = "def";
dt.Rows.Add(dr);
dv = dt.DefaultView;
dataGridView1.DataSource = dv;
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
try
{
dv.RowFilter = "code like'%" + textBox1.Text.Trim() + "%'";
}
catch { }
}