Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1125
Wingrid Checkboxes and Cancelling from BeforeCellUpdate
posted

Hi

We have some code that performs an action as soon as the user ticks a field in a grid. 

I'm forcing the update to happen as soon as the cell is ticked using:

    Private Sub LocalityDRLUltraGrid_CellChange(sender As Object, e As CellEventArgs) Handles LocalityDRLUltraGrid.CellChange
        If e.Cell.Column.Key = "IsCurrentOption" Then
            e.Cell.Row.Update()
        End If
    End Sub

And allowing the user to cancel the action with this code:

    Private Sub LocalityDRLUltraGrid_BeforeCellUpdate(sender As Object, e As BeforeCellUpdateEventArgs) Handles LocalityDRLUltraGrid.BeforeCellUpdate
        Select Case e.Cell.Column.Key
            Case "IsCurrentOption"
                If e.NewValue = False Then
                    e.Cancel = (MessageBox.Show("Marking a locality as non-current will automatically mark all associated GP practices as non-current.  Do you wish to continue?", _
                                               "Mark locality non-current", MessageBoxButtons.YesNo) = DialogResult.No)
                End If
        End Select
    End Sub

This very nearly works perfectly, the only glitch is that if the user chooses to cancel the update the checkbox is still un-checked.  This is only a UI thing, the value in the underlying object is correctly unchanged and as soon as the the user moves cell/row the cell then flicks back to being checked again.  

Is this expected behaviour?   Is there anyway to force the cell to reload it's value from the datasource when the change is cancelled (without reloading the entire grid)?