Tuesday, September 21, 2010

Capturing the value of a databound DataGridViewCheckBoxCell

I had a DataGridViewCheckBoxColumn in my DataGridView that was bound to a BindingSource. I wanted to capture the value of the CheckBoxCell when a user checked or unchecked the cell. So I set the TrueValue and FalseValue for the cell and used the

satelliteScenesDataGridView["inCartDataGridViewCheckBoxColumn", e.RowIndex].Value

But this was always returning false even if the checkbox was checked. After scouring the web I found that you have to use

satelliteScenesDataGridView["inCartDataGridViewCheckBoxColumn", e.RowIndex].EditedFormattedValue

this returns the formatted value of the cell even if the value has not been commited.

No comments:

Post a Comment