bool getcheckboxvalue = (bool)this.DataGrid.Rows["yourcheckbox"].Cells["yourcheckbox"].Value;
             

解决方案 »

  1.   


    for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
    {
    DataGridViewCheckBoxCell cell = (DataGridViewCheckBoxCell)this.dataGridView1.Rows[i].Cells[0];
    if (cell.Value != null && (bool)cell.Value == true)
    {
    //处于选中状态
    }
    }
      

  2.   

    如果你需要一选中就有效果的话,建议使用如下代码private void DATAGRIDVIEW_CurrentCellDirtyStateChanged(object sender, EventArgs e)
            {
                DATAGRIDVIEW.CommitEdit(new DataGridViewDataErrorContexts());
            }private void DATAGRIDVIEW_CellValueChanged(object sender, DataGridViewCellEventArgs e)
            {
                if ((bool)DATAGRIDVIEW.Rows[e.RowIndex].Cells[e.ColumnIndex].Value)
                    MessageBox.Show(string.Format("选中了行{0}", e.RowIndex));
                else
                {
                    MessageBox.Show(string.Format("行{0}被反选了", e.RowIndex));
                }
            }
      

  3.   

    for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
    {
        DataGridViewCheckBoxCell cell = (DataGridViewCheckBoxCell)this.dataGridView1.Rows[i].Cells[0];
        if (cell.Value != null && (bool)cell.Value == true)
        {
            //处于选中状态
        }
    }
      

  4.   

       选中
          if (this.dataGridView1[列索引,行索引].FormattedValue.ToString().Trim()=="True")
          未选中
          if (this.dataGridView1[列索引,行索引].FormattedValue.ToString().Trim() == "False")
            注意True 和 False开头字母大写