We have found a serious bug in RadGridView for WinForms, whereby the user can become completely "trapped" in the application when entering an invalid value in a cell, then scrolling the grid.
You can reproduce the behaviour using the Winforms demo application: Demo Application - RadControls for WinForms Q3 2012:
1. Enter an invalid value in a cell, and press enter.
2. Scroll the grid, by clicking in the scroll bar.
3. Now you're stuck, if you scroll back the entered value is gone, but the row is still in error.
So, how to work around this? One suggestion is to override the CloseEditor :
and then in the New() of the form (where MyGridView is the name of my grid):
This kind of works, but it always closes the editor whenever the user clicks anywhere outside the invalid cell. It avoids the problem of being trapped, but the behaviour is strange - you wouldn't expect the invalid value to disappear when you click outside the cell. The desired behaviour is that the editor is closed if the user scrolls.
One approach I tried without success is to disable scrolling while a grid cell is in edit mode, but no luck.
Does anyone have a good workaround for this tricky problem?
You can reproduce the behaviour using the Winforms demo application: Demo Application - RadControls for WinForms Q3 2012:
1. Enter an invalid value in a cell, and press enter.
2. Scroll the grid, by clicking in the scroll bar.
3. Now you're stuck, if you scroll back the entered value is gone, but the row is still in error.
You are truly stuck, you can't clear the original error. The only way out I found is to force quit the demo application via the Task Manager.
By the way, don't click the down scroll box (I mean the little triangle at the bottom of the scroll bar) or the app will start scrolling endlessly and eventually crash.
So, how to work around this? One suggestion is to override the CloseEditor :
Public Class MyGridViewEditManager
Inherits GridViewEditManager
Public Sub New(ByVal gridView As RadGridViewElement)
MyBase.New(gridView)
End Sub
Public Overrides Function CloseEditor() As Boolean
Dim closeOnFail As Boolean = Me.CloseEditorWhenValidationFails
Me.CloseEditorWhenValidationFails = True
Dim result As Boolean = MyBase.CloseEditor()
Me.CloseEditorWhenValidationFails = closeOnFail
Return result
End Function
End Class
and then in the New() of the form (where MyGridView is the name of my grid):
Me.MyGridView.GridViewElement.EditorManager = New MyGridViewEditManager(Me.MyGridView.GridViewElement)
This kind of works, but it always closes the editor whenever the user clicks anywhere outside the invalid cell. It avoids the problem of being trapped, but the behaviour is strange - you wouldn't expect the invalid value to disappear when you click outside the cell. The desired behaviour is that the editor is closed if the user scrolls.
One approach I tried without success is to disable scrolling while a grid cell is in edit mode, but no luck.
Does anyone have a good workaround for this tricky problem?