Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Which event is occuring in DataGridView in edit mode when user pressed 'Enter'?

Which event is occuring in DataGridView in edit mode when user pressed 'Enter'?

Scheduled Pinned Locked Moved C#
helpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dragan Matic
    wrote on last edited by
    #1

    When user is editing a DataGridView cell I can not find a way to capture event when user presses 'Enter' key. In OnCellEndEdit there is no way to see which button was pressed, OnKeyDown and OnKeyPress simply do not detect 'Enter' key, they act as if it wasn't even pressed. If I try to add event handler to editing control by getting the control in EditingControlShowing and then adding event handler KeyPress or KeyDown on editing control, it also acts as if 'Enter' wasn't pressed. I've tried googling on this, but can't find it anywhere. I'd appreciate any help or hint on this. Dragan Matic

    C 1 Reply Last reply
    0
    • D Dragan Matic

      When user is editing a DataGridView cell I can not find a way to capture event when user presses 'Enter' key. In OnCellEndEdit there is no way to see which button was pressed, OnKeyDown and OnKeyPress simply do not detect 'Enter' key, they act as if it wasn't even pressed. If I try to add event handler to editing control by getting the control in EditingControlShowing and then adding event handler KeyPress or KeyDown on editing control, it also acts as if 'Enter' wasn't pressed. I've tried googling on this, but can't find it anywhere. I'd appreciate any help or hint on this. Dragan Matic

      C Offline
      C Offline
      C1AllenS
      wrote on last edited by
      #2

      Hello Dragan, You can try the following code under the KeyPress() event. If Asc(e.KeyChar) = 13 Then MsgBox("Enter Pressed") End If I hope this helps. Regards, Allen

      Allen Smith Software Engineer ComponentOne LLC www.componentone.com

      D 1 Reply Last reply
      0
      • C C1AllenS

        Hello Dragan, You can try the following code under the KeyPress() event. If Asc(e.KeyChar) = 13 Then MsgBox("Enter Pressed") End If I hope this helps. Regards, Allen

        Allen Smith Software Engineer ComponentOne LLC www.componentone.com

        D Offline
        D Offline
        Dragan Matic
        wrote on last edited by
        #3

        No, that's the catch. Once you start editing text in the DataGridView cell and press Enter (when you want to finish editing), it isn't caught in either KeyPress, KeyDown or any other Key event. Well I suppose it is caught somewhere but I can't find where. Thanks for the answer, anyway Dragan

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups