I have a form with a grid on it, as well as some other controls. I can click between the grid and the other controls without any issues until I edit a cell using a custom editor through Editor Required. It seems that the grid may still be trying to give the control focus even through it isn't valid any more? Unfortunately the error only occurs on my test machine and not my dev machine, so I doubt that giving a sample would help. I am providing through the relevant snippets of code in the hopes that I am just doing something obviously wrong with setting up the custom editor.
First, this is the exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at Telerik.WinControls.UI.ImeSupport.CreateContext()
at Telerik.WinControls.UI.ImeSupport.OnGotKeyboardFocus(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnGotFocus(EventArgs e)
at Telerik.WinControls.RadControl.OnGotFocus(EventArgs e)
at Telerik.WinControls.UI.RadGridView.OnGotFocus(EventArgs e)
at System.Windows.Forms.Control.WmSetFocus(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at Telerik.WinControls.RadControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
This is the custom editor class:
Private Class CustomTextEditor
Inherits Telerik.WinControls.UI.RadTextBoxControlEditor
Public Overrides Sub OnKeyDown(e As Forms.KeyEventArgs)
Try
If e.KeyCode = Forms.Keys.Enter Then
Dim Cell As Telerik.WinControls.UI.GridDataCellElement = DirectCast(Me.OwnerElement, Telerik.WinControls.UI.GridDataCellElement)
Dim View As Telerik.WinControls.UI.MasterGridViewTemplate = DirectCast(Cell.ViewTemplate, Telerik.WinControls.UI.MasterGridViewTemplate)
View.Owner.EndEdit()
Else
MyBase.OnKeyDown(e)
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class
I still get the exception even if I never actually process any of my custom enter key code (it just passes through to MyBase.OnKeyDown
This is the code that creates the editor
Private Sub OnCustomEditor(sender As Object, e As Telerik.WinControls.UI.EditorRequiredEventArgs)
Try
e.EditorType = GetType(CustomTextEditor)
Catch ex As Exception
Util.Exceptions.Exception.Display(ex)
End Try
End Sub
I initially called e.Editor = New CustomTextEditor(), but changed to set EditorType after some examples I found. However it doesn't make any difference.