在DataGridView中获得DataGridViewCheckBoxColumn的状态
当我们选中该Cell后,第1时间得到的该值为:
dgView1.Rows(i).Cells(1).Value = False
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
//MessageBox.Show(dataGridView1.Columns[e.ColumnIndex].CellTemplate.ToString());
if (dataGridView1.RowCount > 0 && e.RowIndex > -1)
{
string action = dataGridView1.Columns[e.ColumnIndex].Name;
if (action == "BtnDel")
{
string ID = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
MessageBox.Show(ID);
}
if (action == "isUse")
{
string value = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
MessageBox.Show(value);
}
}
}
if (MessageBox.Show("确定删除吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.No)
{
return;
}