c# winforms
My DataGridView has:
SelectionMode - CellSelect
EditMode - EditOnKeyStroke
It works well for all Keys except fot DeleteKey (when pressed - nothing happend).
I want - if DeleteKey is pressed - selected Cell (or Cells) stay selected, but - empty value (like in Excel).
Must I create a separate KeyDownEvent for DeleteKey only ?
Loading

VulpesPosted Jun 4, 2012, 8:55 AM
Try something like the following:
VulpesPosted Jun 4, 2012, 10:14 AM
If the entire cell is selected then pressing the 'Delete' key does nothing, as you say.
However, if only the contents of the cell are selected, then the 'Delete' key works as expected even without my code.
It may be that, in the first case, the Delete key does nothing because you can't, of course, delete an entire cell - you can only delete its contents.
MementoPosted Jun 4, 2012, 9:34 AM
Your code works, asUsual.
But I'm wondering about MSLogic.
If dgv is in FullRowSelectMode - DelKey deletes selectedRow.
If dgv is in CellSelectMode - it should be naturally to delete cellContent (or maybe cellItself).
What does it mean that - DelKey - deletes Nothing !
Is there some hidenReason ?
AnyWay - ThanksForYourCode.