C# 我想显示在datagridview中选中复选框的行,并隐藏未选中的其他行
我有一个datagridview和一列复选框,我的代码是C# 我想显示在datagridview中选中复选框的行,并隐藏未选中的其他行,c#,checkbox,datagridview,C#,Checkbox,Datagridview,我有一个datagridview和一列复选框,我的代码是 private void button2_Click(object sender, EventArgs e) { DataGridViewRow row = new DataGridViewRow(); for (int i = 0; i < dataGridView1.Rows.Count; ++i) { row = dataGridView1.Rows[i];
private void button2_Click(object sender, EventArgs e)
{
DataGridViewRow row = new DataGridViewRow();
for (int i = 0; i < dataGridView1.Rows.Count; ++i)
{
row = dataGridView1.Rows[i];
if (Convert.ToBoolean(row.Cells[0].Value) == true)
{
this.dataGridView1.DataSource =
}
}
}
private void按钮2\u单击(对象发送者,事件参数e)
{
DataGridViewRow行=新建DataGridViewRow();
对于(int i=0;i
刚开始时,请确保您可以做到:
dataGridView1.CurrentCell = null;
您不需要数据源来完成这项工作。但是如果你想再次展示它们,你可能需要它
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (!Convert.ToBoolean(row.Cells[0].Value))
{
dataGridView1.CurrentCell = null;
row.Visible = false;
}
}
无法使未提交的新行不可见。我编辑了答案。在使行可见false=>dataGridView1.CurrentCell=null之前只需添加这一行;让我知道结果。谢谢你的帮助。你写的第二篇文章使我受益匪浅
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (!Convert.ToBoolean(row.Cells[0].Value))
{
dataGridView1.CurrentCell = null;
row.Visible = false;
}
}