How to know a specific checkbox inside datagridview is checked or not?

后端 未结 4 2126
遇见更好的自我
遇见更好的自我 2020-12-11 12:13

i had a gridview which has 2 columns , one is textbox column and other is checkbox column, how to know which checkbox is checked .

4条回答
  •  离开以前
    2020-12-11 12:32

    private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
    {
        if (e.ColumnIndex == *someIndex*)
        {
            DataGridViewCheckBoxCell cell = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex] as DataGridViewCheckBoxCell;
            if (cell != null)
            {
                if (cell.EditingCellValueChanged)
                {
                    //CheckBox has been clicked
                }
    
                //here how to get the checkBoxCell value
                var cellChecked = cell.EditingCellFormattedValue;
            }
        }
    }
    

提交回复
热议问题