I have an UltraWinGrid, where I want multiple cell selection to be possible in only one way : iff the user holds down the CTRL/SHIFT key and selects by clicking the cells.
I do not want users to be able to drag over a region to select multiple cells. How can this be accomplished? I am currently using v7.3. Thanks.
Something along this line might work for you (the code is in vb):
In InitializeLayout:
e.Layout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect
e.Layout.Override.SelectTypeCell = Infragistics.Win.UltraWinGrid.SelectType.Extended
e.Layout.Override.SelectTypeCol = Infragistics.Win.UltraWinGrid.SelectType.None
e.Layout.Override.SelectTypeRow = Infragistics.Win.UltraWinGrid.SelectType.None
The code above will cause nothing to be selected when the user clicks on a cell or column. The cell's row is activated on click, but no selection takes place. This will also allow for multiply cell selection in code (see below).
In UltraGrid_ClickCell
If ModifierKeys = (ModifierKeys.Shift + ModifierKeys.Control) Then
myUltraGrid.Selected.Cells.Add(e.Cell)
Else
myUltraGrid.Selected.Cells.Clear()
End
I couldn't do the first part, because I need the selected cell value, and it was selecting a row. Since the user can also select multiple cells on the same row, this was not an option.
I did however try the ClickCell code, but that didnt solve the problem of disabling drag selection of multiple cells. Here's my code snippet
void grid_ClickCellButton(object sender, CellEventArgs e) { if (grid.Selected.Cells.Count < 1) grid.Selected.Cells.Add(e.Cell); else if ((ModifierKeys == Keys.Shift) || (ModifierKeys == Keys.Control)) grid.Selected.Cells.Add(e.Cell); }
How do i disable the "drag selection" ... i.e. when in a grid, If I click while moving the mouse and hold the click, it selects multiple cells. This could pose a problem in my application. I just want the cell capturing the actual click to be selected, not the whole selection. Thanks.
I have this line in my InitializeComponent() function
grid.DisplayLayout.Override.SelectTypeCell =
SelectType.ExtendedAutoDrag;
And this has disabled selection dragging. However , I do have drag n drop enabled , so my mouse down and mouse move events trigger that. The only way I can select multiple rows is by holding down shift or ctrl.
Hi Santosh,
I tried this out with both SelectTypeCell and SelectTypeRow and my suggestion above does not seem to work with either of them - much to my surprise.
Perhaps I was mistaken in my original post, but I cannot find any way to turn off selection dragging now.
You should Submit a feature request to Infragistics
Hi Mike,
This solution is not working for me in case of
SelectTypeRow = SelectType.ExtendedAutoDrag. I need to select multiple rows only when I having Ctrl or Shift key is pressed.
Regards,
Santosh
Thanks a lot! this is exactly what I wanted.
If you need the users to be able to select multiple cells using Shift+Click or Ctrl+Click, and you want to disabled just the dragging selection, you should use SelectType.ExtendedAutoDrag.
I guess that may seem a little weird that you need to choose AutoDrag in order to turn off dragging selection. But drag in this case refers to the ability to click on a cell and begin dragging the selected cells to some other control, not dragging the selection itself.
Of course, if you just want single selection and don't want the user to select multiple objects at all, you could just use SelectType.Single.