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. How to prevent DataGridView from skipping to next row after edit/Enter

How to prevent DataGridView from skipping to next row after edit/Enter

Scheduled Pinned Locked Moved C#
tutorialquestion
4 Posts 3 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

    Is there a way to prevent a DataGridView with TextBox fields from skipping to next row after pressing Enter after editing value in Cell? In cell Edit mode it automatically goes to next row after pressing Enter. I've tried overriding OnKeyDown, OnCellEndEdit, OnCellLeave, EditingControlShowing and adding handler to TextBox control, but there seems to be an event occuring after all those events and I can't find where to catch the event where DataGridView finished editing cell and skips to next row. Any Ideas? Tnx in advance Dragan Matic

    A C 2 Replies Last reply
    0
    • D Dragan Matic

      Is there a way to prevent a DataGridView with TextBox fields from skipping to next row after pressing Enter after editing value in Cell? In cell Edit mode it automatically goes to next row after pressing Enter. I've tried overriding OnKeyDown, OnCellEndEdit, OnCellLeave, EditingControlShowing and adding handler to TextBox control, but there seems to be an event occuring after all those events and I can't find where to catch the event where DataGridView finished editing cell and skips to next row. Any Ideas? Tnx in advance Dragan Matic

      A Offline
      A Offline
      Andrei Ungureanu
      wrote on last edited by
      #2

      Dragan Matic wrote:

      there seems to be an event occuring after all those events and I can't find where to catch the event

      You can always use Spy++ to see what events occur, and their order. Hope it helps.

      I will use Google before asking dumb questions

      1 Reply Last reply
      0
      • D Dragan Matic

        Is there a way to prevent a DataGridView with TextBox fields from skipping to next row after pressing Enter after editing value in Cell? In cell Edit mode it automatically goes to next row after pressing Enter. I've tried overriding OnKeyDown, OnCellEndEdit, OnCellLeave, EditingControlShowing and adding handler to TextBox control, but there seems to be an event occuring after all those events and I can't find where to catch the event where DataGridView finished editing cell and skips to next row. Any Ideas? Tnx in advance Dragan Matic

        C Offline
        C Offline
        CodingEntrigue
        wrote on last edited by
        #3

        Count you not just set the AllowUsertoAddRows property of the datagrid to false?

        D 1 Reply Last reply
        0
        • C CodingEntrigue

          Count you not just set the AllowUsertoAddRows property of the datagrid to false?

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

          No, because I have a problem with editing the cells. After I enter some text in the cell, and after pressing Enter and if there is another row under the current one, the cell under the edited one becomes selected. Setting AllowUserstoAddRows to false will not change that behavior. And if I add event handler to say, CellEndEdit and move it somewhere else (say, to the next cell in the same row), some other event moves the active cell to the next column after that, so I get active cell moved one place right and one place down. I cannot find where that event is occurring.

          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