Is cellvaluechanged event suitable for this ? how?
void filterDataGridView(DataGridView dgv, string columnName, string filterValue)
{
foreach (DataGridViewRow row 开发者_如何学编程in dgv.Rows)
{
if (row.Cells[columnName].Value.ToString().Contains(filterValue))
{
row.Visible = true;
}
else row.Visible = false;
}
}
i need too send cell value that user write it,to filtervalue of my function.how can i do that?
If you want to react on the user typing text in on of your cells I would recommend CellValidating event.
- You write some text in on of your cells
- Cell_validating occurs
- you call your filter method and you may modify some other dataGrid (in your example hide/show rows on given value)
HTH
精彩评论