datagridview 隐藏行
datagridview 隐藏行,选中一行不能隐藏,选中2行以上才可以,这是怎么回事啊
private void lblAddDevice_Click(object sender, EventArgs e) { for (int i = 0; i < dgvDevice.Rows.Count;i++ ) { DataGridViewCheckBoxCell chkCell = (DataGridViewCheckBoxCell)dgvDevice.Rows[i].Cells["Check"]; Boolean flag = Convert.ToBoolean(chkCell.Value); if (flag) { CurrencyManager cm = (CurrencyManager)BindingContext[this.dgvDevice.DataSource]; cm.SuspendBinding(); dgvDevice.Rows[i].Visible = false; cm.ResumeBinding(); //disAbleCheck(i); } }}
bool flag = Convert.ToBoolean(chkCell.EditedFormattedValue);
[解决办法]
for (int i = 0; i < dataGridView1.Rows.Count; i++) { DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)dataGridView1.Rows[i].Cells["Check"]; if ((Boolean)chk.EditedFormattedValue == true) {}}