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?
In the CellChange event:
foreach (var childRow in parentRow.Childbands[0].Rows)
{
childRow.Delete();
}
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); } } }
You're right. Didn't test it.
how about if you have nest children?
in my case I have forms with a child of cats which has a child of items, which has a child of values...
What I am wanting is something that will make rowstates as deleted on all nested children, as the user is only going to see band[0] (forms)
When you delete a row from the grid, the grid asks the BindingManager in DotNet to delete that row. As far as I know, this is not recursive - it doesn't walk down the chain and delete the child rows. You would have to handle this yourself in code.
Hello Ravi,
Do you need some kind of assistance regarding this topic? Please let me know, I will be happy to help you.
Dear Sir,
Please give me your email id .
My email id is rspanday.n@gmail.com
thanks,
Ravi