winform筛选数据
文章引自:
http://www.cnblogs.com/spgoal/archive/2006/09/04/494665.html
代码如下:
View Code
string InputStr = tbKey.Text;
foreach (DataGridViewRow dvr in dataGridView1 .Rows)
{
if (dvr.Cells[0].Value.ToString().StartsWith(InputStr))
{
dataGridView1.ClearSelection();
dvr.Selected = true;
dataGridView1.CurrentCell = dvr.Cells[1];
break;
}
}
foreach (DataGridViewRow dvr in dataGridView1 .Rows)
{
if (dvr.Cells[0].Value.ToString().StartsWith(InputStr))
{
dataGridView1.ClearSelection();
dvr.Selected = true;
dataGridView1.CurrentCell = dvr.Cells[1];
break;
}
}