I have tow bands in my wingrid. When the value in parent band changes, I want to delete all the rows in the child band. Can somebody tell me how to do it?
Hi,
Amiram, did you test this code? It seems to me like this is very dangerous and might even cause an exception. You should never remove items from a collection in a ForEach loop, since removing items will change the size of the collection and thus mess up the indexer.
Here's some safer code:
private void DeleteAllChildRows(UltraGridRow parentRow) { foreach (UltraGridChildBand childBand in parentRow.ChildBands) { UltraGridRow[] rows = (UltraGridRow[])childBand.Rows.All; foreach (UltraGridRow row in rows) { row.Delete(false); } } }
In the CellChange event:
foreach (var childRow in parentRow.Childbands[0].Rows)
{
childRow.Delete();
}