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
120
How to click the selector without canceling the selection status of other rows.
posted

Now click on the Row selector and a menu will pop up. The menu will operate on the selected rows.

But when I select multiple rows, then left click on the Row selector, the selected state of other selected rows will be canceled.

I want to know how to keep the selection state of other rows not canceled after clicking the row selector.

Thank you very much.

Parents
  • 29045
    Verified Answer
    Offline posted

    Hello Stan, 

    Thank you for contacting Infragistics. The behavior you are seeing is similar to multiple row selection works within the grid records/cells and to be expected. Holding down the shift key is the only way to extend multiple selection you already had outside of drag selection. Left-clicking will be treated as starting over unless you hold down the shift key. You can trap when and if the shift is pressed in the BeforeSelectionChange to decide if you want to extend or start a new selection by hooking the BeforeSelectChange event. Keep in  mind that you aren't going to be able to easily manipulate the selection in this event, and I don't recommend canceling unless you are certain of the user commands to invoke a new selection. 

    eg. The following example cancels any new selection on a single left click. However if you already have multiple selection a shift press won't invoke a new selection. You have to click and drag down using the left mouse on the row selectors. The sample attached below ensures a single row via left clicking won't deselect any previous multi-selection. I mainly tested this only with row selectors. Let me know what you think. UltraGridSelectedRowsContextMenu.zip

     bool trippedFlag = false;
            private void ultraGrid1_BeforeSelectChange(object sender, Infragistics.Win.UltraWinGrid.BeforeSelectChangeEventArgs e)
            {
                UltraGrid grid = sender as UltraGrid;
                var selected = grid.Selected;
                
                if (Control.ModifierKeys != Keys.Shift && e.NewSelections.Rows.Count == 1 && selected.Rows.Count != 0)
                {
                    trippedFlag = true;
                    e.Cancel = true;
                }
                else if (trippedFlag == true)
                {
                    e.Cancel = true;
                }
               
            }

Reply Children