Getting the checkbox state from a checkboxcolumn in datagridview
Posted on 2007-10-15
I've built a databound checkbox column as follows.
DataGridViewCheckBoxColumn checkboxColumn = new DataGridViewCheckBoxColumn();
checkboxColumn.HeaderText = "P/Work Received";
checkboxColumn.Name = "chkPaperwork_Received";
checkboxColumn.DataPropertyName = "chkPaperworkReceived";
checkboxColumn.TrueValue = "Y";
checkboxColumn.FalseValue = "N";
checkboxColumn.Width = 60;
idx = dgvNbmu.Columns.Add(checkboxColumn);
When a checkbox on a row is clicked, I capture the event and try to process it as follows:
CheckBox cb = new CheckBox();
cb.Checked = (bool)dgvNbmu.Rows[e.RowIndex].Cells["chkPaperwork_Received"].Value;
The problem is that the dgvNbmu.Rows[e.RowIndex].Cells["chkPaperwork_Received"].Value is still "Y", which is the original value.
As the checkbox was already checked, I am expecting to get a false value from somewhere.
Am I looking in the wrong place, if so, where should I be getting the latest value of the checkbox from ?