This is a migrated thread and some comments may be shown as answers.

Delete key

5 Answers 388 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Gabor
Top achievements
Rank 1
Gabor asked on 22 Jul 2008, 01:51 PM
Hi,

I would like to use a RadGridView and be able to tell when the user pressed the delete key. It's important that the grid does NOT actually delete the current row, but it seems like disabling this causes the KeyDown event not to fire when the delete key was pressed. Is this an intended behaviour? Please advise,

Thanks,
Gabor

5 Answers, 1 is accepted

Sort by
0
Gabor
Top achievements
Rank 1
answered on 23 Jul 2008, 09:31 AM
Hi,

I just learned that pressing the delete key does not fire a keydown event, but it does fire a keyup event when the button is released. So my problem is solved, however I still not understand why this behaviour is intended.

Best wishes
Gabor
0
Nikolay
Telerik team
answered on 25 Jul 2008, 01:17 PM
Hi Gabor,

The keydown event is processed by the RadGridView and because of this you can't process it within the KeyDown event. Rather, you should create a descendant class of RadGridView and process the OnKeyDown method there.

As to canceling the delete operation, you can subscribe to the RowsChanging event and if the Action is Remove, cancel it:
 
private void radGridView1_RowsChanging(object sender, Telerik.WinControls.UI.GridViewCollectionChangingEventArgs e)  
{  
    if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Remove)  
    {  
        e.Cancel = true;  
    }  

If you have additional questions, feel free to contact me.
 

Sincerely yours,
Nikolay
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Denius
Top achievements
Rank 1
answered on 25 Aug 2016, 10:34 AM

Please , help me

I must restrict mouse wheel , and keydown also keyUp arrows ... in telerik GridView when numeric field is in edit mode.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 26 Aug 2016, 07:09 AM
Hello Goran,

Thank you for writing. 

In order to handle mouse and keyboard input while editing the grid, it is necessary to subscribe to the respective events of the initialized editor. The following help article demonstrates a approach: http://docs.telerik.com/devtools/winforms/gridview/editors/handling-editors'-events

If you need to disable changing the editor's value with the mouse wheel, you can set the GridSpinEditorElement.EnableMouseWheel property to false after the editor is initialized:
this.radGridView1.CellEditorInitialized+=radGridView1_CellEditorInitialized;

private void radGridView1_CellEditorInitialized(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
{
   GridSpinEditor editor = e.ActiveEditor as GridSpinEditor;
   if (editor!=null)
   {
       GridSpinEditorElement element = editor.EditorElement as GridSpinEditorElement;
       element.EnableMouseWheel = false;
   }
}

As to the arrow keys, you can disable changing the value by setting the GridSpinEditorElement.InterceptArrowKeys property to false.

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Denius
Top achievements
Rank 1
answered on 26 Aug 2016, 08:00 AM
Thank you wery muck it's works fine !
Tags
GridView
Asked by
Gabor
Top achievements
Rank 1
Answers by
Gabor
Top achievements
Rank 1
Nikolay
Telerik team
Denius
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or