We've upgraded our WinForms project from 15.2 to 17.1.
When editing (changing a cell value) and leaving the ultrawingrid the exception occurs, it's not being caught within the VS 2017 IDE as I've set it to break on this exception.
The code is quite old, I think it's going wrong in this part of the code, as I've stepped through the code and set the activecell to nothing, which stops the exception occuring.
Dim ThisCell As UltraGridCell = Me.ActiveCell If Not ThisCell Is Nothing Then If ThisCell.IsInEditMode Then Me.PerformAction(UltraGridAction.ExitEditMode, False, False) If ThisCell.IsInEditMode Then OutputTrace(ts.TraceWarning, "Cannot exit edit mode on leave, cell and row may not be updated or validated") End If End If If IsDirty(ThisCell) Then Dim ThisE As New CancelableCellEventArgs(ThisCell) RaiseEvent ValidateCell(ThisGrid, ThisE) If ThisE.Cancel Then Me.Focus()
ElseIf mValidationModeCell = IProgressDataEntryGrid.ValidationModeConstants.Always Then Dim ThisE As New CancelableCellEventArgs(ThisCell) RaiseEvent ValidateCell(ThisGrid, ThisE) If ThisE.Cancel Then Me.Focus()
Else 'nothing to validate on cell End If End If
Has there been any changes in this area that would affect the operation, if so do you have any recommendations?
Many thanks
Keith
Hi Keith,
I looked into that error message and it occurs when the MaskedEditor is in the middle of an operation and tries to verify that it is still in edit mode.
You didn't say what event this code is called from. But my guess is that you are calling this in a Key or Mouse event and there's a masked editor in a grid cell that is trying to process that key or mouse operation and you are forcing the cell out of edit mode while it's in the middle of that process.
If that's the case, then a potential solution to that problem would be to institute some sort of delay instead of synchronously exiting edit mode in response to whatever event you are using. You can typically do that with a BeginInvoke.
Another possibility is that this is a threading issue. That seems unlikely since you seem to imply that the error is pretty consistent and threading issues tend to be inconsistent and only happen intermittently. Is your application using multiple threads? Are you creating a BackgroundWorker or other thread?
The reason you can't catch the exception is most likely because you have "Just My Code" debugging turned on in Visual Studio. So you probably just need to turn that off in order to catch the exception and see the call stack. To turn it off go to Tools-->Options-->Debugging and uncheck "Enable Just My Code."
Hi, I also upgraded to 17.1 (from 16.1) and am experiencing the same behavior. I cannot figure out where the error is occurring because it is being caught in my unhandled error routine. Here is the exact error:
StellarSystemsPM.exe Error: 0 : [HeaterMain]: [HeaterMain]: System.InvalidOperationException: Operation can not be performed when not in edit mode. at Infragistics.Win.EditorWithMask.EnsureInEditMode() at Infragistics.Win.EditorWithMask.get_Sections() at Infragistics.Win.EditorWithMask.OnControlLeave(Object sender, EventArgs e) at System.EventHandler.Invoke(Object sender, EventArgs e) at System.Windows.Forms.Control.OnLeave(EventArgs e) at Infragistics.Win.UltraWinGrid.UltraGrid.OnLeave(EventArgs e) at System.Windows.Forms.Control.NotifyLeave() at System.Windows.Forms.ContainerControl.UpdateFocusedControl()
I also attached a screenshot of my Debug options scre
I would appreciate any guidance...thanks!
Steve