Delete key

6 posts, 0 answers
  1. Gabor
    Gabor avatar
    4 posts
    Member since:
    Jun 2008

    Posted 22 Jul 2008 Link to this post

    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
  2. Gabor
    Gabor avatar
    4 posts
    Member since:
    Jun 2008

    Posted 23 Jul 2008 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 25 Jul 2008 Link to this post

    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
  5. Denius
    Denius avatar
    11 posts
    Member since:
    Oct 2015

    Posted 25 Aug in reply to Nikolay Link to this post

    Please , help me

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

  6. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 26 Aug Link to this post

    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 sample 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.
  7. Denius
    Denius avatar
    11 posts
    Member since:
    Oct 2015

    Posted 26 Aug in reply to Dess Link to this post

    Thank you wery muck it's works fine !
Back to Top
UI for WinForms is Visual Studio 2017 Ready