Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Delete a row programmatically in DataGridView

$
0
0

How can I delete a newly added row with code in a DataGridview? I cannot find any delete method in any of the features of the DataGridView.

 

I test for correct data in the _RowValidating event that sets cancel to true. But when the user leaves the row without correcting the value, I set e.cancel = True. But the row is still there with the invalid value in one of the cells. I want to delete the row if the data are not correct and the user navigates away from the row. Can this be done? Is RowValidating event the correct place to do the delete? How and where should I do it?


Viewing all articles
Browse latest Browse all 12583


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>