.net - How to remove a cell programatically from DataGridView in Windows Forms using C#? -


i need remove cell based on condition datagridview of windows forms.

below code.

private void grdvtest_databindingcomplete(object sender, datagridviewbindingcompleteeventargs e) {     try     {         var grdv = sender datagridview;          foreach (datagridviewrow row in grdv.rows)         {             datagridviewcell bookbuttoncell = row.cells[0];             viewmodelmyitem item = row.databounditem viewmodelmyitem;              if (item.isdeleted)             {                 row.cells.remove(bookbuttoncell);             }         }     }     catch (exception ex)     {         throw ex     } } 

error at:

row.cells.remove(bookbuttoncell); 

collection belongs datagridview control. operation no longer valid.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -