private void FilterButton_Click(object sender, EventArgs e) { DataTable dt = ((DataTable)DataGridView2.DataSource); foreach (DataGridViewRow row in DataGridView2.Rows) { // Test if the first column of the current row equals // the value in the text box if ((String)row.Cells["Month"].Value == birthdayMonth.Text) { // we have a match row.Selected = true; } else { row.Selected = false; } } }
row.Cells["Month"].Value
birthdayMonth.Text
Quote:DataView dv = ((DataTable)DataGridValue.DataSource).DefaultView; dv.RowFilter = "ColumnName < TB1 AND ColumName > TB2" Afterwards bind the DataView to your gridView
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)