Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User unable to delete row in DataGridView

Status
Not open for further replies.

aprobe

Programmer
Dec 4, 2003
36
NZ
I have an unbound DataGridView. Previously I was able to select the row header and press the Delete key to delete the row. This no longer works. I don't know when it stopped working. I have 'AllowUserToDeleteRows' set to True.

The entire row is selected and pressing the Delete key erases the contents of the first column and does not remove the row.
Obviously the 'UserDeletingRow' event is not fired because the row is not deleted.

Just to clarify I am not trying to delete any data, will handle this manually as the grid is unbound, I just want the visible row of the grid the user sees to be deleted.

Does anyone have any idea what may have caused this behaviour?
 
After many hours of searching have found the cause of the problem.

When you have the 'EditMode' property of the DataGridView set to 'EditOnEnter' you cannot delete the row even if you select the entire row on the row header and press the delete key.

I have reset it to 'EditOnKeystroke' or 'EditOnKeystrokeOrF2' and it is now working correctly again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top