c# - Deleting multiple rows in datagridview -


i need delete top 1000 rows in 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         {             (int = 0; < 1000; i++ )             {                 form.gridtestreport.rows.removeat(0);              }         }      } 

this deletes rows takes lot of time. ui non-responsive when delete in progress. better way delete multiple rows.

thanks

as not using binding or virtual mode, everytime remove row, entire grid refreshed. painfully slow.

as dealing large amount of data, use virtual mode efficietly update grid.

see this msdn link more information. there walkhrough available. takes little time setup once done faster ane makes life easier.

also see best practices scaling windows forms datagridview control maximum out datagridview.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -