2
Answers

DataGridView - how to delete Row

Abdul Asif

Abdul Asif

16y
48.9k
1

Hi all,

I am working on C# project using C# 2.0. I have a DataGrid that contains 10 rows and at runtime I insert one more row at DataGridView.Insert(0,1); in my next step, I want to delete the row from DataGridView at DataGridView.RemoveAt(9) // Index 9 is the last row in the grid. But, I am not able to delete the row. I am getting following exception: System.InvalidOperationException:Uncommitted new row cannot be deleted. at System.Windows.Forms.DataGridViewRowCollection.RemoveAt(Int32 index)

Please help if you know the solution.

Thanks in advance for your help.

Answers (2)