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

后端 未结 4 2130
遇见更好的自我
遇见更好的自我 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:29

     private void dataGridView1_CurrentCellDirtyStateChanged(object sender, EventArgs e)
        {
            if (dataGridView1.IsCurrentCellDirty)
            {
                dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit);
            }
        }
    
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (((e.ColumnIndex) == 1) && ((bool)dataGridView1.Rows[e.RowIndex].Cells[1].Value))
            {
                MessageBox.Show(dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString());
    
            }
        }
    

    these below links helped me to understand the concept of cellvalue_changed and cell_content_click.. http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.cellvaluechanged.aspx

    and by the help of these links i finally got the solution to my problem

提交回复
热议问题