Update DataGridView Cell value [modified]
-
Hi, I have a DataGridView control containing several columns one of which is a CheckBoxColumn. Clicking any of the CheckBoxes in this column fires the CellContentClick event which perfoms a task using the value of the clicked CheckBox. However, the value of the CheckBox doesn't seem to update until the cell loses focus, which is a problem for the task I am trying to achieve. Anybody help me on this one? Thanks. EDIT : Sorted it I think using the CommitEdit method of the grid.
modified on Wednesday, August 5, 2009 7:46 AM
-
Hi, I have a DataGridView control containing several columns one of which is a CheckBoxColumn. Clicking any of the CheckBoxes in this column fires the CellContentClick event which perfoms a task using the value of the clicked CheckBox. However, the value of the CheckBox doesn't seem to update until the cell loses focus, which is a problem for the task I am trying to achieve. Anybody help me on this one? Thanks. EDIT : Sorted it I think using the CommitEdit method of the grid.
modified on Wednesday, August 5, 2009 7:46 AM
Perhaps you can move the task from the CellContentClick event to the DataGrid's MouseUp event ? Determine which cell has been clicked there, and because MouseUp happens after the rest, the CheckBox value should be resolved and ready for you to use.
My advice is free, and you may get what you paid for.
-
Hi, I have a DataGridView control containing several columns one of which is a CheckBoxColumn. Clicking any of the CheckBoxes in this column fires the CellContentClick event which perfoms a task using the value of the clicked CheckBox. However, the value of the CheckBox doesn't seem to update until the cell loses focus, which is a problem for the task I am trying to achieve. Anybody help me on this one? Thanks. EDIT : Sorted it I think using the CommitEdit method of the grid.
modified on Wednesday, August 5, 2009 7:46 AM
-
In the
CellContentClick
event, you will get the updated value in theEditedFormattedValue
property of the cell and not in theValue
property.It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
Great, just what I was looking for - thanks :D