Oliver
  • Oliver
  • Advanced Member Topic Starter
2014-01-10T13:19:15Z
Is there an event to catch the change of the cell-checkbox AFTER it is applied to the cell?

Currently, I can use the CellCheckChange event to catch the change BEFORE it is happening and maybe cancel the operation. In my case, I need to change the formatting of the row AFTER any change in checkbox state. The function used for applying the format depends on the state of the checkbox and if I call it from CellCheckChange it reads the wrong (old) state as the change did not apply yet.

Problem and Workarounds:

' Wrong:
Private Sub m_objGrid_CellCheckChange(ByVal lRow As Long, ByVal lCol As Long, eNewCheckState As iGrid500_10Tec.ECellCheckState, bCancel As Boolean)
    Select Case lCol
    Case objGrid.ColIndex("Check")
        formatRow lRow ' <- does get the "old" CellCheckState(lRow, lCol)
    Case Else
        ' do nothing
    End Select

End Sub

' Workaround 1:
Private Sub m_objGrid_CellCheckChange(ByVal lRow As Long, ByVal lCol As Long, eNewCheckState As iGrid500_10Tec.ECellCheckState, bCancel As Boolean)
    Select Case lCol
    Case objGrid.ColIndex("Check")
        formatRow lRow, eNewCheckState ' <- feels like cheating, because the CellCheckState(lRow, lCol) is not yet set
    Case Else
        ' do nothing
    End Select

End Sub

' Workaround 2:
Private Sub m_objGrid_CellCheckChange(ByVal lRow As Long, ByVal lCol As Long, eNewCheckState As iGrid500_10Tec.ECellCheckState, bCancel As Boolean)
    Select Case lCol
    Case objGrid.ColIndex("Check")
        objGrid.CellCheckState(lRow, lCol) = eNewCheckState ' <-- forcing it to be set now works and is consistent, but feels wrong too because it's not this functions job.
        formatRow lRow
    Case Else
        ' do nothing
    End Select

End Sub

' This is what i dream of:
Private Sub m_objGrid_AfterCellCheckChange(ByVal lRow As Long, ByVal lCol As Long)
    Select Case lCol
    Case objGrid.ColIndex("Check")
        formatRow lRow ' <-- can read the new CellCheckState
    Case Else
        ' do nothing
    End Select

End Sub

In the end, I would need something like an AfterCellCheckState event, just like AfterCommitEdit.

Regards,
Oliver

P.S.: Happy New Year!
Igor/10Tec
2014-01-11T07:56:47Z
Oliver, you are right - the general editing events like BeforeCommitEdit/AfterCommitEdit aren't triggered for cell check boxes as they are used to indicate that the cell value is changed, but not the check mark. If you need an AfterCellCheckState event, you can set the timer with the minimal interval in the CellCheckChange event and then process the timer's event which in fact will be fired after the check state has been changed.

I also noted your suggestion for the future major updates of iGrid.
Igor/10Tec
2015-12-01T15:19:14Z
We have implemented the AfterCellCheckChange event in iGrid ActiveX 6.0 based on your suggestion.