I have a parent/child relation in ultrawingrid. I want to be able to select multiple child rows but within the same parent. if the user selects from a different parent, i do not want to allow that selection. Is there any way we can do this?
For our purposes, using BeforeSelectChange wasn't quite what we wanted as you could still have an active row "selected" under a different parent. We ended up using something like this:
private void ultraGrid1_BeforeRowActivate(object sender, RowEventArgs e) { var firstSelectedInBand = ultraGrid1.Selected.Rows.OfType() .FirstOrDefault(x => x.Band == e.Row.Band); if (firstSelectedInBand == null) return; if (e.Row.ParentCollection != firstSelectedInBand.ParentCollection) ugPlan.Selected.Rows.Clear(); }
Thanks a lot Mike... Its working prefectly fine
Many Thanks
Amjath
Hi,
There's no property setting of this, but you can do it pretty easily in code.What you do is handle the BeforeSelectChange and loop through the new selected rows. If the collection contains rows from different rows collections, then you cancel the selection.
Something like this:
void ultraGrid1_BeforeSelectChange(object sender, BeforeSelectChangeEventArgs e) { if (e.NewSelections.Rows.Count > 1) { RowsCollection rows = e.NewSelections.Rows[0].ParentCollection; for (int i = 1; i < e.NewSelections.Rows.Count; i++) { if (e.NewSelections.Rows[i].ParentCollection != rows) { e.Cancel = true; return; } } } }