Home Forums WinForms controls Xceed Grid for WinForms The cell’s attempt to leave edit mode has been cancelled.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #16796 |

    I am getting the following exception when setting e.cancel = true when handling the Cell.LeavingEdit Event of the DataRowTemplate.  the column is using a Xceed.Grid.Editors.ComboBoxEditor for its editor.  I am using the EnteringEdit and LeavingEdit to track if the user actually changes the value or not.  If they do not change the value I cancel the change so that hte bound dataset does not appear dirty.

     The cell’s attempt to leave edit mode has been cancelled.

    This is not a hard error, but if I set the debugger to throw all CLR errors this one comes up every time I set e.cancel = true. The exception is not caught in the event handler but appears at my Application.Run line, but also does not cause the application to terminate.

            Try
                ‘Compare the new value with the old value, if they are not the same then there was a true change
                If (e.NewValue Is Nothing) AndAlso (mCurrentValue = String.Empty) Then
                    ‘NewValue will be nothing if either no selection or no data was entered
                    e.Cancel = True
                Else
                    If (e.NewValue IsNot Nothing) AndAlso (e.NewValue.ToString = mCurrentValue) Then
                        e.Cancel = True
                    Else
                        e.Cancel = False
                    End If
                End If
            Catch ex As Exception
                e.Cancel = False
            End Try

     

    Here is the full dump of the exception.

    Xceed.Grid.GridException occurred
      Message=”The cell’s attempt to leave edit mode has been cancelled.”
      Source=”Xceed.Grid”
      StackTrace:
           at Xceed.Grid.CellEditorManagerCore.EndEdit(Boolean commit)
      InnerException:
     

    Imported from legacy forums. Posted by Brian (had 2490 views)

    User (Old forums)
    Member
    Post count: 23064

    And you will not see the exception when not in debug mode, because this is an exception that is thrown and swallowed by the gird.  Since it is your code that intentionally raises this exception, you can simply ignore it.  It is there to help you debug when a problem arise.

    Imported from legacy forums. Posted by André (had 256 views)

    User (Old forums)
    Member
    Post count: 23064

    I am not sure how in my code I am intentionally raising this exception.  In the event there is a cancel flag in the event args that I am using to cancel the edit.  Not sure that I understand how this translates to my code intentionally raising the exception.

     Is there a way to stop it from doing that?

    Imported from legacy forums. Posted by Brian (had 385 views)

    User (Old forums)
    Member
    Post count: 23064

    Setting e.Cancel to true will make the exception raise, and it is not possible to stop it doing that.

    Now remember this is only when debugging, this will not happen at runtime, the exception will be swallowed.

    Imported from legacy forums. Posted by André (had 2927 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.