Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
370
RowSelectorHeaderUIElement in OutlookGroupedBy ViewStyleBand
posted

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

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted


            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);
                }
            }   

Children