如何在datagridview中过滤数据 [英] how filter data in datagridview
本文介绍了如何在datagridview中过滤数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我手动将数据插入datagridview
I manually insert data to datagridview
dataGridView1.Rows.Add(fio, doljnost, ats, gats, tetra, fax, _dopn);
如何过滤datagridview数据?
How filter datagridview data ?
推荐答案
i希望这段代码对你有所帮助..
i hope this code helps you a bit..
rivate void button1_Click(object sender, EventArgs e)
{
string searchValue = textBox1.Text;
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
try
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Cells[2].Value.ToString().Equals(searchValue))
{
row.Selected = true;
//break;
//if u want use break;
}
}
}
catch (Exception exc)
{
MessageBox.Show(exc.Message);
}
}
首先创建数据视图
并绑定datagridview的数据源
你应该在数据视图上插入/更新/删除/ ...
和最终使用datafilter of dataview
first create dataview
and bind datasource of datagridview
you should do insert/update/delete/... on dataview
and final use rowfilter of dataview
这篇关于如何在datagridview中过滤数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文