现在有一个DataGridView,它的第一列是Checkbox列,我想在选中某一个checkbox之后,获得该checkbox的值。
例如:
    第一行 第一列的checkbox是选中状态,我点击它之后,触发事件(这个事件我也不知道是什么),然后我获得它的值。 本人总共70分,奉送35分。谢谢各位。

解决方案 »

  1.   

    事情不是onclick吗?在控件上双击,事件不就自动生成了?
    楼主想获得checkbox的什么值啊?
    是否checked,这个有属性,要想获得文字,自己.tostring就好了
      

  2.   

    用CurrentCellChanged事件
    private void dataGridView1_CurrentCellChanged(object sender, EventArgs e)
    {
        if (dataGridView1.CurrentCell == null)
            return;
        else if (dataGridView1.CurrentCell.ColumnIndex == 0)
            MessageBox.Show(dataGridView1.CurrentCell.Value.ToString());  
    }
      

  3.   

    貌似 chenkbox只有true和false
      

  4.   

    CellValueChanged 事件
      private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
            {
                if (e.RowIndex != -1)
                {
                    if (Boolean.Parse((this.dataGridView1.Rows[e.RowIndex].Cells[0] as DataGridViewCheckBoxCell).Value.ToString()))
                    {
                       你想做的事!
                    }
                    else
                    {
       你想做的事!
                     
                    }
                }
            }
      

  5.   

    使用 CurrentCellChanged 事件处理; 
    在其中使用先判断是否为 NULL 值,Null 值代表没有选择; 
    之后判断其True/False 即可。
      

  6.   

    使用 CurrentCellChanged 事件处理; 
    在其中使用先判断是否为 NULL 值,Null 值代表没有选择; 
    之后判断其True/False 即可。
      

  7.   

    使用 CurrentCellChanged 事件处理; 
    在其中使用先判断是否为 NULL 值,Null 值代表没有选择; 
    之后判断其True/False 即可。