Lets say that i select 4 rows to be deleted and hit delete. I would now like to verify something per row and if the row fails i would like to remove it from the "to be deleted" collection. So if 1 of my 4 rows fails then only 3 will be deleted.
For Each aRow As Infragistics.Win.UltraWinGrid.UltraGridRow In e.Rows Ticket = Lookup("tblSchedule", "ID", "InvoiceID=123") If GP.IsNotBlank(Ticket) Then 'This is where i would like to remove the row End IfNext
I solved this by iterating through all the rows (like you are doing) and select them first, then after the loop is complet call the DeleteSelectedRows method from the UltraGrid object.
I.E.
For Each aRow in e.Rows...
If GP.IsNotBlank(Ticket)...
aRow.Selected = True
End If
Next
e.DeleteSelectedRows()
I'm using this in 14.2 right now.
Even if you that, C# doesn't allow to alter a collection in the middle of a foreach loop.
You can write this in the event handler to cancel the deletion and initiate your own:
e.Cancel =
true;
ultraGrid1.EventManager.SetEnabled(
GridEventIds.BeforeRowsDeleted, false);
e.Rows[0].Delete(); // or any thing else you want to delete
GridEventIds.BeforeRowsDeleted, true);