Does anyone know how can I find out what the child rows are (or their parent row) when the row selector element in a group is clicked? I have used the AfterRowExpanded event successfully to get the parent row, but if several groups are already expanded and the user returns to a previously expanded group to click the row selector, I don't then parent row is the wrong one.
(The reason for this is that I want to select all of the rows within the OutlookGroup with one mouse-click for subsequent copy/paste/Excel export/etc.)
A screen-shot is attached.
Thanks in advance,
Richard
private void ultraGrid1_MouseUp(object sender, MouseEventArgs e) { // Get the grid. UltraGrid grid = (UltraGrid)sender; // Get the last element entered by the mouse. UIElement element = grid.DisplayLayout.UIElement.LastElementEntered; // See if the element is a RowSelectorHeaderUIElement. RowSelectorHeaderUIElement rowSelectorHeaderUIElement = element as RowSelectorHeaderUIElement; // If it's not, see if one of it's ancestors is. if (rowSelectorHeaderUIElement == null) rowSelectorHeaderUIElement = element.GetAncestor(typeof(RowSelectorHeaderUIElement)) as RowSelectorHeaderUIElement; // If we still haven't found a RowSelectorHeaderUIElement by now, just exit. if (rowSelectorHeaderUIElement == null) return; // Get hte rows associated with the RowSelectorHeaderUIElement RowsCollection rows = rowSelectorHeaderUIElement.GetContext(typeof(RowsCollection)) as RowsCollection; // Clear any existing selection. grid.Selected.Rows.Clear(); // If there are rows in the list, select them all. if (rows != null ) { UltraGridRow[] rowsArray = (UltraGridRow[])rows.All; grid.Selected.Rows.AddRange(rowsArray); } }
Thanks for the quick response Mike.
My C# isn't very good. Can you please do a VB.net version instead as my translation doesn't seem to work. eg I'm not sure what the following is trying to do:
RowSelectorHeaderUIElement rowSelectorHeaderUIElement = element as RowSelectorHeaderUIElement;
Thanks,