Posted 14 January 2021, 7:57 pm EST
I use the following code to remove row, but when I save the datasource I binding, this row still be there
grid.Rows.Remove(grid.Rows[grid.Selection.TopRow]);
Forums Home / ComponentOne / WPF Edition
Posted by: malishin on 14 January 2021, 7:57 pm EST
Posted 14 January 2021, 7:57 pm EST
I use the following code to remove row, but when I save the datasource I binding, this row still be there
grid.Rows.Remove(grid.Rows[grid.Selection.TopRow]);
Posted 14 January 2021, 11:22 pm EST
Hi Malishin,
Rows’s Remove method only removes the row from the FlexGrid’s rows collection. Therefore, in order to delete a row from the data source you have to delete it from the FlexGrid’s CollectionView as follows:
int rowIndex = flexGrid.Selection.TopRow;
var dataItem = flexGrid.Rows[rowIndex].DataItem;
(flexGrid.CollectionView as ListCollectionView).Remove(dataItem);
Best Regards,
Kartik
Posted 4 February 2021, 5:43 pm EST
Thanks ,it works