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.
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.
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