locked
DataGridView deleting all rows RRS feed

  • Question

  • I am loading data to a data grid, and allowing the user to take options to load different data.

    How do I get rid of the rows (clear the grid) when ever I want to load new data?

    Right now, it is appending the new data as additional rows, leaving the old data as well.
    Monday, August 3, 2009 4:43 PM

Answers

  • You can use dataGridView1.Rows.Clear().
     Or
    Clear the items from the DataSource that the DataGridView is bound to, if any (e.g. DataTable.Rows.Clear()    OR Collection.Clear())
    • Marked as answer by JimGuyer Monday, August 3, 2009 8:05 PM
    Monday, August 3, 2009 7:06 PM