Thank you for sharing the code snippet.
According to the provided piece of code, it seems that after you press Keys.Enter, an item gets updated by the values of the current row's cells. I believe that this part of the code can be successfully moved to the CellValueChanged
event. Thus, no matter whether Tab or Enter key is pressed, once the value is committed to the cell, the CellValueChanged
event will be fired and you will be able to store the changes to the item you need.
However, if you still prefer the way of handling the editor's key, note that it is necessary to subscribe to the PreviewKeyDown
event of the hosted TextBox
inside the editor:
AddHandler Me.RadGridView1.CellEditorInitialized, AddressOf RadGridView1_CellEditorInitialized
Private Sub RadGridView1_CellEditorInitialized(sender As Object, e As Telerik.WinControls.UI.GridViewCellEventArgs)
Dim tbEditor As RadTextBoxEditor = TryCast(e.ActiveEditor, RadTextBoxEditor)
If Not tbEditor Is Nothing Then
Dim tbElement As RadTextBoxEditorElement = CType(tbEditor.EditorElement, RadTextBoxEditorElement)
RemoveHandler tbElement.TextBoxItem.TextBoxControl.PreviewKeyDown, AddressOf TextBoxControl_PreviewKeyDown
AddHandler tbElement.TextBoxItem.TextBoxControl.PreviewKeyDown, AddressOf TextBoxControl_PreviewKeyDown
Private Sub TextBoxControl_PreviewKeyDown(sender As Object, e As PreviewKeyDownEventArgs)
If e.KeyData = Keys.Enter Then
ElseIf e.KeyData = Keys.Tab Then
Feel free to use this approach which suits your requirements best.
Should you have further questions please let me know.
Dess | Tech Support Engineer, Sr.
Progress is here for your business, like always. Read more
about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.