OptionPage: How to capture Key events? RRS feed

  • Question

  • Hi,

    I have a custom language service which also provides some custom OptionPages (ie, pages that are integrated in the default Visual Studio Options-Dialog). This basically works great, except for one isse: I cannot capture key-press events (especially Enter and Escape events).

    To be more precise, I have a DataGridView on my OptionPage. The user can edit single cells. The usual way to stop editing is to either press Enter (ie, accept cell changes), or Escape (discard cell changes). However, pressing Enter/Escape does not end the DataGridViewCell's Edit-Mode, but rather ends the entire Options dialog. It's like clicking the dialog'S OK or Cancel button, although we simply want to exit the currently edited cell.

    Is there any way to capture these events and handle them properly? I couldn't manage to get any KeyDown event of the DataGridView to actually fire.


    Monday, November 17, 2014 9:45 PM


  • Hi Max,

    I think this is by design, because it's the same for the Visual Studio IDE's own Option window. The Option window will capture the Enter or Esc key press event. If you want to process the key press events, you could try to P/Invoke SetWindowsHookEx function:


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by f_max Wednesday, November 19, 2014 8:24 AM
    Wednesday, November 19, 2014 6:41 AM