How to prevent DataGridView from skipping to next row after edit/Enter
-
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
-
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
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
-
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
Count you not just set the AllowUsertoAddRows property of the datagrid to false?
-
Count you not just set the AllowUsertoAddRows property of the datagrid to false?
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.