.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
Post a Comment