Abdul Asif

Abdul Asif

  • NA
  • 27
  • 0

DataGridView - how to delete Row

Nov 25 2007 5:43 AM

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)