Groups | Blog | Home
all groups > vb.net controls > february 2007 >

vb.net controls : datagridview control - What event fires when you (un)check checkbox?


DesperateDan
2/6/2007 8:23:35 AM
Can't believe I'm asking this but......

I've got a datagridview control which has a checkbox column.

I want to enable an UPDATE button as soon as any checkbox has changed
(checked/unchecked).

I'm currently trapping the event CellValueChanged however it doesn't
fire unless you lose focus from that particular cell. (i.e. you gotta
click on another cell for example to fire the event)

Thanks in anticipation.
Dan
danielfernandes.mail NO[at]SPAM gmail.com
2/7/2007 5:19:58 AM
[quoted text, click to view]

I haven't had the chance to use .Net 2.0 at work but I came accross
this http://msdn2.microsoft.com/en-us/library/
system.windows.forms.datagridview.cellvaluechanged(VS.80).aspx

The DataGridView.CellValueChanged event occurs when the user-specified
value is committed, which typically occurs when focus leaves the cell.

In the case of check box cells, however, you will typically want to
handle the change immediately. To commit the change when the cell is
clicked, you must handle the DataGridView.CurrentCellDirtyStateChanged
event. In the handler, if the current cell is a check box cell, call
the DataGridView.CommitEdit method and pass in the Commit value.

Hope this helps. Oh and how's my old company by the way ? :)

Dan (not the same one)
DesperateDan
2/7/2007 8:46:52 AM
Fixed it not long after posting this message. You're correct.
That's the event to handle it.

(I daren't answer the "The old company" question as I will be
compelled to be honest!)

Regards

Dan (The original)
AddThis Social Bookmark Button