How to programmable put a new key event

Posted by: kenjon-fp on 8 September 2017, 1:28 pm EST

  • Posted 8 September 2017, 1:28 pm EST

    Hello Club FP,
    I have a menu in my form and in the same form I also have an FpSpread.

    In the menu I have a ‘Delete’ ToolStripMenuItem and I have set the ShortcutKeys property to the Delete key.

    The effect of this is that when the delete button is hit I end up in the DeleteToolStripMenuItem.Click event.

    If my FpSpread is the selected control I want selected text to be deleted.
    How to achieve this?
    I have tried to put a new key event in the Spread with OnKeyDown(New KeyEventArgs(Keys.Delete)) if my FpSpread is the selected control.
    But it doesn’t work.
  • Replied 8 September 2017, 1:28 pm EST

    The menu shortcut is consuming the DELETE and it never gets sent to the spreadsheet.

    I did find some info in this thread

    and also in this 





     Is it impossible to programmatly sent a new DELETE to spreadsheet?
     


     

  • Replied 8 September 2017, 1:28 pm EST

    Hello,


    When the Spread get's focus, you could disable this shortcut key. Ot you can catch this key event in the menu and if the active control is the Spread control, then you can programatically delete the data you want.

  • Replied 8 September 2017, 1:28 pm EST

    Thanks,
    Disabling the shortcut key then Spread get’s focus and enable it again when any other control get focus made it for me.

    Catching the key event in the menu does not work for me.
    I didn’t find out how to delete only selected text, not all text

  • Replied 8 September 2017, 1:28 pm EST

    Hello,


    You can get the editor control (FpSpread1.EditingControl) from the Spread if it is in EditMode and query the properties of the EditingControl to find out the text that is selected so you can change the text property to the correct text when the Del key is pressed.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels