dataGridView 怎么显示指定的行,其他的不显示。希望有详细的代码,谢谢!

如题所述

dataGridView的数据源是DataTable,DataTable有主键的话好处理.
假设dataGridView.DataSource=this.dt;dt的col1列主键

显示当前行
this.dt.DefaultView.RowFilter = "col1=" + dataGridView1.CurrentRow.Cells["col1"].Value.ToString();

显示所有行
this.dt.DefaultView.RowFilter = string.Empty

如果是自定义的List的绑定,可能会麻烦点,重新绑定一次数据源只取当前行的数据.
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-08-09
//设置不需要显示的行
dataGridView1.Rows[i].Visible=false;
第2个回答  2011-08-09
dgv.Rows[i].visible 可以设置的
相似回答
大家正在搜