Deleting multiple rows in datagridview

Anup D

I need to delete top 1000 rows in a datagridview.

delegate void DeleteRowsCallback(); 
    private static void Delete1KRows()
    {
        JSONTest form = (JSONTest)Application.OpenForms["JSONTest"];
        if (form.GridTestReport.InvokeRequired)
        {
            DeleteRowsCallback d = new DeleteRowsCallback(Delete1KRows);
            form.GridTestReport.Invoke(d);

        }
        else
        {
            for (int i = 0; i < 1000; i++ )
            {
                form.GridTestReport.Rows.RemoveAt(0);

            }
        }

    }

This deletes the rows but takes lot of time. Also the UI is non-responsive when the delete is in progress. Any better way to delete multiple rows.

Thanks

Junaith

As you are not using any binding or virtual mode, everytime you remove a row, the entire grid is refreshed. It would be painfully slow.

As you are dealing with large amount of data, use Virtual Mode to efficietly update the grid.

See this MSDN link for more information. There is a Walkhrough available. It takes little time to setup but once it is done it would much faster ane makes life easier.

Also see Best Practices for Scaling the Windows Forms DataGridView Control to get the maximum out DataGridView.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

List of deleting rows in datagridview

From Dev

Trying to delete selected row from datagridview but it is deleting multiple rows

From Dev

Index was out of range after deleting multiple rows from the datagridview? C#

From Dev

Uncatchable exception in DataGridView when deleting rows in datatable

From Dev

Deleting multiple rows from a table

From Dev

Deleting multiple rows from a table

From Dev

Deleting rows of data for multiple variables

From Dev

Deleting multiple rows from TableView

From Dev

Deleting rows based on multiple conditions Python Pandas

From Dev

Deleting multiple rows in Excel using Apache POI

From Dev

Deleting rows from multiple tables with jQuery

From Dev

Deleting multiple rows at once with Doctrine DBAL, is it possible?

From Dev

Deleting Rows Based on Multiple Cell Values

From Dev

Multiple rows deleting in jtable with the same value

From Dev

Deleting multiple rows with array of _id mongodb

From Dev

Selecting Multiple Rows from DataGridView using Linq

From Dev

Display rows from multiple DataTables in single DataGridView

From Dev

select multiple rows from datagridview and show the IDs

From Dev

Deleting multiple rows using checkboxes in Struts2

From Dev

Python - NumPy - deleting multiple rows and columns from an array

From Dev

Deleting multiple rows by ids and checking if those ids are not in other tables

From Dev

Deleting multiple rows based on where clause using FluentMigrator

From Dev

Deleting DataFrame rows in Pandas based on column value - multiple values to remove

From Dev

Deleting multiple rows in R based on a is.na condition

From Dev

Deleting/Highlighting Duplicate rows in Excel across multiple columns

From Dev

Deleting rows based on multiple Joins and where statements in SQL

From Dev

deleting multiple rows using check boxes with jquery in django?

From Dev

SQLITE3 - Deleting rows that have multiple columns of the same value

From Dev

Dynamically add multiple rows in datagridview in vb.net

Related Related

  1. 1

    List of deleting rows in datagridview

  2. 2

    Trying to delete selected row from datagridview but it is deleting multiple rows

  3. 3

    Index was out of range after deleting multiple rows from the datagridview? C#

  4. 4

    Uncatchable exception in DataGridView when deleting rows in datatable

  5. 5

    Deleting multiple rows from a table

  6. 6

    Deleting multiple rows from a table

  7. 7

    Deleting rows of data for multiple variables

  8. 8

    Deleting multiple rows from TableView

  9. 9

    Deleting rows based on multiple conditions Python Pandas

  10. 10

    Deleting multiple rows in Excel using Apache POI

  11. 11

    Deleting rows from multiple tables with jQuery

  12. 12

    Deleting multiple rows at once with Doctrine DBAL, is it possible?

  13. 13

    Deleting Rows Based on Multiple Cell Values

  14. 14

    Multiple rows deleting in jtable with the same value

  15. 15

    Deleting multiple rows with array of _id mongodb

  16. 16

    Selecting Multiple Rows from DataGridView using Linq

  17. 17

    Display rows from multiple DataTables in single DataGridView

  18. 18

    select multiple rows from datagridview and show the IDs

  19. 19

    Deleting multiple rows using checkboxes in Struts2

  20. 20

    Python - NumPy - deleting multiple rows and columns from an array

  21. 21

    Deleting multiple rows by ids and checking if those ids are not in other tables

  22. 22

    Deleting multiple rows based on where clause using FluentMigrator

  23. 23

    Deleting DataFrame rows in Pandas based on column value - multiple values to remove

  24. 24

    Deleting multiple rows in R based on a is.na condition

  25. 25

    Deleting/Highlighting Duplicate rows in Excel across multiple columns

  26. 26

    Deleting rows based on multiple Joins and where statements in SQL

  27. 27

    deleting multiple rows using check boxes with jquery in django?

  28. 28

    SQLITE3 - Deleting rows that have multiple columns of the same value

  29. 29

    Dynamically add multiple rows in datagridview in vb.net

HotTag

Archive