How to delete row from DataGridview
-
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. A.Asif
A.Asif
-
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. A.Asif
A.Asif
Hey asif, I suppose you are looping first and then find the row to delete and then you delete the row. Please do that...Loop through the grid from backward and then remove the row. Hope this help..
Regards Pankaj Joshi If you want to shape your dreams into reality, please wake-up...
-
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. A.Asif
A.Asif