MultiRow Windows Forms > Developer's Guide > Using MultiRow > Grid > Selection Mode |
The GcMultiRow control provides two types of user selection modes. The developer can add or delete the selected cells, retrieve the selection, and set the appearance of the selected cells. Refer to Selecting Cells using Headers for details on the selection of cells using headers.
GcMultiRow supports the selection of multiple cells by default. The user can select multiple cells by dragging the cells, clicking on the header, or by clicking or dragging the cells while pressing the Ctrl key. The following image shows cells being dragged in the multi select mode. The triangle icon depicts the mouse cursor.
You can select discontinuous cells when you click on the cells while pressing the Ctrl key.
The following code sets the MultiSelect property for the GcMultiRow control.
GcMultiRow1.MultiSelect = True |
gcMultiRow1.MultiSelect = true; |
This specifies whether the developer will let the user select a single cell or multiple cells at a time. To enable the single select mode, set the GcMultiRow.MultiSelect property to False.
The following code sets the single select mode for the GcMultiRow control.
GcMultiRow1.MultiSelect = False |
gcMultiRow1.MultiSelect = false; |
You can select or delete the cell selection using the Cell.Selected property.
The following example selects a cell.
GcMultiRow1.Rows(0).Cells(1).Selected = True |
gcMultiRow1.Rows[0].Cells[1].Selected = true; |
For selecting and deleting the selection of rows, use the Row.Selected property (Section.Selected property).
The following example selects a row.
GcMultiRow1.Rows(0).Selected = True |
gcMultiRow1.Rows[0].Selected = true; |
To determine whether the cells or rows are selected, refer to Selected Rows and Cells.
The background and the foreground of the cells change to display them in a selected state when the cells are selected. The backcolor and forecolor use the CellStyle.SelectionBackColor property and the CellStyle.SelectionForeColor property, but the effect of the rendering varies depending on the rendering process and the style settings. For details, refer to Cell Styles.
Set the GcMultiRow.AllowUserToReverseSelect property to True to reverse the selection of the already selected cells, or, in other words, to delete the selection of some of the cells from a selected range. In this case, the user can reverse the selection by pressing Ctrl with the mouse click.
The following code lets users reverse the selection by pressing the Ctrl key while clicking.
GcMultiRow1.AllowUserToReverseSelect = True |
gcMultiRow1.AllowUserToReverseSelect = true; |
Set the GcMultiRow.AllowUserToShiftSelect property to True to be able to select multiple cells, either by specifying the start and end of the selection while pressing the Shift key, or by dragging the mouse over the selection while pressing the Shift key.
The following example sets the grid to allow users to select multiple cells while pressing the Shift key.
GcMultiRow1.AllowUserToShiftSelect = True |
gcMultiRow1.AllowUserToShiftSelect = true; |
To allow mouse handling and to disable keyboard handling, delete the shortcut keys that are associated with this operation.
The following code lets the user press Shift and use the mouse to select multiple cells, but not to use the keyboard and Shift to select multiple cells.
Imports GrapeCity.Win.MultiRow GcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftDown) GcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftLeft) GcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftPageDown) GcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftPageUp) GcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftRight) GcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftToFirstCell) GcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftToFirstCellInRow) GcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftToFirstRow) GcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftToLastCell) GcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftToLastCellInRow) GcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftToLastRow) GcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftToNextRow) GcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftToPreviousRow) GcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftUp) |
using GrapeCity.Win.MultiRow; gcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftDown); gcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftLeft); gcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftPageDown); gcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftPageUp); gcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftRight); gcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftToFirstCell); gcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftToFirstCellInRow); gcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftToFirstRow); gcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftToLastCell); gcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftToLastCellInRow); gcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftToLastRow); gcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftToNextRow); gcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftToPreviousRow); gcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.ShiftUp); |