单行选中
foreach (DataGridViewRow dr in this.dataGridView1.Rows)
{
try
{
//DataGridViewCheckBoxCell cbx = (DataGridViewCheckBoxCell)dr.Cells[0];
//if ((bool)cbx.FormattedValue)
if(dr.Cells[0].Selected)
{
arrShiftCode.Add(dr.Cells[1].Value);
arrShiftGroup.Add(dr.Cells[2].Value);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
多行选中
foreach (DataGridViewRow dr in this.dataGridView1.Rows)
{
try
{
DataGridViewCheckBoxCell cbx = (DataGridViewCheckBoxCell)dr.Cells[0];
if ((bool)cbx.FormattedValue)
{
arrShiftCode.Add(dr.Cells[1].Value);
arrShiftGroup.Add(dr.Cells[2].Value);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}