Delete all rows from datagridview
-
Hi all, I can delete the selected rows from datagridview by selecting the rows and pressing the del key: SqlCommandBuilder cb_imp = new SqlCommandBuilder(myda); myconn.Open(); myda.Update(mydt); Bud what's the way to delete all rows without selecting??? Thanx.
-
Hi all, I can delete the selected rows from datagridview by selecting the rows and pressing the del key: SqlCommandBuilder cb_imp = new SqlCommandBuilder(myda); myconn.Open(); myda.Update(mydt); Bud what's the way to delete all rows without selecting??? Thanx.
Hello, Well if you do not want to select all rows and then delete, then you can implement that in Button Click or some menu selection. Use this code to delete all the rows. You will have to manually loop through the rows and delete them one by one.
for (int i = this.dataGridView1.Rows.Count - 2; i > -1; i--) this.dataGridView1.Rows.RemoveAt(i);
I hope this will help. Regards,Allen Smith ComponentOne LLC www.componentone.com
-
Hello, Well if you do not want to select all rows and then delete, then you can implement that in Button Click or some menu selection. Use this code to delete all the rows. You will have to manually loop through the rows and delete them one by one.
for (int i = this.dataGridView1.Rows.Count - 2; i > -1; i--) this.dataGridView1.Rows.RemoveAt(i);
I hope this will help. Regards,Allen Smith ComponentOne LLC www.componentone.com
Hi Allen, This works well. thanx a lot