MultiRow Windows Forms > Developer's Guide > Using MultiRow > Grid > Shortcut Keys |
You can use shortcut keys to work with the GcMultiRow control using the keyboard.
The default shortcut keys for the grid vary depending upon the view mode. The following table shows the actions versus the allocation of keys in various modes. Please refer to View Modes for details on the grid view modes.
Group or Actions | Description | Default Mode | Row Mode | Display Mode | Listbox Mode |
---|---|---|---|---|---|
SelectionActions | |||||
MoveDown | Move to the cell below. | Keys.Down | - | - | - |
MoveUp | Move to the cell above. | Keys.Up | - | - | - |
MoveLeft | Move to the cell on the left. | Keys.Left | - | - | - |
MoveRight | Move to the cell on the right. | Keys.Right | - | - | - |
MoveToFirstCell | Move to the first cell of the first row. | Keys.Control + Keys.Home | - | - | - |
MoveToLastCell | Move to the last cell of the last row. | Keys.Control + Keys.End | - | - | - |
MoveToPreviousCell | Move to the previous cell (regardless of the row). | Keys.Shift + Keys.Tab OR Keys.Control + Keys.Shift + Keys.Tab | Keys.Shift + Keys.Tab OR Keys.Control + Keys.Shift + Keys.Tab | - | - |
MoveToNextCell | Move to the next cell(regardless of the row). | Keys.Tab OR Keys.Control + Keys.Tab | Keys.Tab OR Keys.Control + Keys.Tab | - | - |
MoveToFirstCellInRow | Move to the first cell of the current row. | Keys.Home OR Keys.Control + Keys.Left | Keys.Home OR Keys.Control + Keys.Left | - | - |
MoveToFirstCellByTabOrder | Move to the first cell in the tab order. | - | - | - | - |
MoveToFirstCellInRowByTabOrder | Move to the first cell in the tab order of the current row. | - | - | - | - |
MoveToLastCellInRow | Move to the last cell of the current row. | Keys.End OR Keys.Control + Keys.Right | Keys.End OR Keys.Control + Keys.Right | - | - |
MoveToLastCellByTabOrder | Move to the last cell in the tab order. | - | - | - | - |
MoveToLastCellInRowByTabOrder | Move to the last cell in the tab order of the current row. | - | - | - | - |
MoveToPreviousCellInRow | Move to previous cell in the current row. | - | - | - | - |
MoveToNextCellInRow | Move to the next cell in the current row. | - | - | - | - |
MoveToFirstRow | Move to the first row. | Keys.Control + Keys.Up | Keys.Control + Keys.Up Keys.Home |
- | Keys.Home |
MoveToLastRow | Move to the last row. | Keys.Control + Keys.Down | Keys.Control + Keys.Down OR Keys.End | - | Keys.End |
MoveToPreviousRow | Move to the previous row. | - | Keys.Up OR Keys.Left | - | Keys.Up |
MoveToNextRow | Move to the next row. | - | Keys.Down OR Keys.Right | - | Keys.Down |
MoveToNextPage | Move to the next page. | Keys.PageDown | Keys.PageDown | - | Keys.PageDown |
MoveToPreviousPage | Move to the previous page. | Keys.PageUp | Keys.PageUp | - | Keys.PageUp |
ReverseSelectCurrentRow | Reverse the selection of the present row. | - | - | - | Keys.Space |
SelectAll | Select all the rows. | Keys.Control + Keys.A | Keys.Control + Keys.A | - | Keys.Control + Keys.A |
SelectRow | Select the current row. | Keys.Shift + Keys.Space | - | - | - |
ShiftDown | Expand or shorten the selected range into the closest cells below. | Keys.Shift + Keys.Down | - | - | - |
ShiftUp | Expand or shorten the selected range into the closest cells above. | Keys.Shift + Keys.Up | - | - | - |
ShiftLeft | Expand or shorten the selected range into the closest cells on the left. | Keys.Shift + Keys.Left | - | - | - |
ShiftRight | Expand or shorten the selected range into the closest cells on the right. | Keys.Shift + Keys.Right | - | - | - |
ShiftToFirstCell | Change the currently selected range from the present cells to the first cell of the first active row. | Keys.Shift + Keys.Control + Keys.Home | - | - | - |
ShiftToLastCell | Change the currently selected range from the present cells to the last cell of the last active row. | Keys.Shift + Keys.Control + Keys.End | - | - | - |
ShiftToFirstCellInRow | Change the currently selected range from the present cells to the first cell of the present row. | Keys.Shift + Keys.Home OR Keys.Shift + Keys.Control + Keys.Left | - | - | - |
ShiftToLastCellInRow | Change the currently selected range from the present cells to the last cell of the present row. | Keys.Shift + Keys.End OR Keys.Shift + Keys.Control + Keys.Right | - | - | - |
ShiftToFirstRow | Change the currently selected range from the present cells to the cell of the first row having the same CellIndex. | Keys.Shift + Keys.Control + Keys.Up | Keys.Shift + Keys.Home OR Keys.Shift + Keys.Control + Keys.Up | - | - |
ShiftToLastRow | Change the currently selected range from the present cells to the cell of the last row having the same CellIndex. | Keys.Shift + Keys.Control + Keys.Down | Keys.Shift + Keys.End OR Keys.Shift + Keys.Control + Keys.Down | - | - |
ShiftToPreviousRow | Change the currently selected range from the present cells to the cell of the previous row having the same CellIndex. | - | Keys.Shift + Keys.Up OR Keys.Shift + Keys.Left | - | - |
ShiftToNextRow | Change the currently selected range from the present cells to the cell of the next row having the same CellIndex. | - | Keys.Shift + Keys.Down OR Keys.Shift + Keys.Right | - | - |
ShiftPageDown | Expand or shorten the selected range to the next page. | Keys.Shift + Keys.PageDown | Keys.Shift + Keys.PageDown | - | - |
ShiftPageUp | Expand or shorten the selected range to the previous page. | Keys.Shift + Keys.PageUp | Keys.Shift + Keys.PageUp | - | - |
ComponentActions | |||||
SelectNextControl | Shift the focus to the next control. | - | - | - | - |
SelectPreviousControl | Shift the focus to the previous control. | - | - | - | - |
EditingActions | |||||
BeginEdit | Start editing of the cells. | Keys.F2 OR Keys.Enter | Keys.F2 OR Keys.Enter | - | - |
EndEdit | Confirm the editing. | Keys.Enter | Keys.Enter | - | - |
CancelCellEdit | Cancel input and exit edit mode when the current cell is in edit mode. | - | - | - | - |
CancelEdit | Cancel the cell editing. | Keys.Escape | Keys.Escape | - | - |
CancelRowEdit |
Cancel Row level editing if current cell is not in edit mode, or if the Dirty state of the cell is set to false. | - | - | - | - |
Cut | Cut the selected cell values to the clipboard. | Keys.Control + Keys.X OR Keys.Shift + Keys.Delete | Keys.Control + Keys.X OR Keys.Shift + Keys.Delete | - | - |
Copy | Copy the selected cell values to the clipboard. | Keys.Control + Keys.C OR Keys.Control + Keys.Insert | Keys.Control + Keys.C OR Keys.Control + Keys.Insert | - | Keys.Control + Keys.C OR Keys.Control + Keys.Insert |
Paste | Copy the selected cell values from the clipboard. | Keys.Control + Keys.V OR Keys.Shift + Keys.Insert | Keys.Control + Keys.V OR Keys.Shift + Keys.Insert | - | - |
Clear | Delete the values of the selected cells. | Keys.Delete | Keys.Delete | - | - |
DeleteSelectedRows | Delete the selected rows. | Keys.Control + Keys.Delete | Keys.Control + Keys.Delete | - | Keys.Control + Keys.Delete |
CommitRow | Commit the row changes. | Keys.Control + Keys.Enter | Keys.Control + Keys.Enter | - | - |
InputNullValue | Input null value. | Keys.Control + Keys.D0 OR Keys.Control + Keys.NumPad0 | Keys.Control + Keys.D0 OR Keys.Control + Keys.NumPad0 | - | - |
ShowDropDown | Display the drop-down window. | Keys.F4 OR Keys.Alt + Keys.Down | Keys.F4 OR Keys.Alt + Keys.Down | - | - |
ScrollActions | |||||
VerticalScrollToFirstPage | Move to the first page in the vertical direction. | - | - | Keys.Control + Keys.Up | - |
VerticalScrollToLastPage | Move to the last page in the vertical direction. | - | - | Keys.Control + Keys.Down | - |
VerticalScrollToPreviousPage | Move to the previous page in the vertical direction. | - | - | Keys.PageUp OR Keys.Shift + Keys.Space | - |
VerticalScrollToNextpage | Move to the next page in the vertical direction. | - | - | Keys.PageDown OR Keys.Space | - |
HorizontalScrollToFirstPage | Move to the first page in the horizontal direction. | - | - | Keys.Home OR Keys.Control + Keys.Left | - |
HorizontalScrollToLastPage | Move to the last page in the horizontal direction. | - | - | Keys.End OR Keys.Control + Keys.Right | - |
HorizontalScrollToPreviousPage | Move to the previous page in the horizontal direction. | - | - | - | Keys.Left |
HorizontalScrollToNextPage | Move to the next page in the horizontal direction. | - | - | - | Keys.Right |
ScrollUp | Move one step up in the vertical direction. | - | - | Keys.Up | - |
ScrollDown | Move one step down in the vertical direction. | - | - | Keys.Down | - |
ScrollLeft | Move one step left in the horizontal direction. | - | - | Keys.Left | - |
ScrollRight | Move one step right in the horizontal direction. | - | - | Keys.Right | - |
The list of default shortcut keys can be retrieved using the following properties of the ShortcutKeyManager.
The following code gets the shortcut keys in default mode using the ShortcutKeyManager.DefaultModeList property.
Imports GrapeCity.Win.MultiRow ' Place the ListView control onto the form ListView1.SuspendLayout() ListView1.View = View.Details ListView1.Columns.Add("Action") ListView1.Columns.Add("Key") For Each shortcutKey As ShortcutKey In GcMultiRow1.ShortcutKeyManager.DefaultModeList Dim item As ListViewItem = New ListViewItem() item.Text = shortcutKey.Action.DisplayName item.SubItems.Add(shortcutKey.Key.ToString()) ListView1.Items.Add(item) Next ListView1.ResumeLayout() |
using GrapeCity.Win.MultiRow; // Place the ListView control onto the form listView1.SuspendLayout(); listView1.View = View.Details; listView1.Columns.Add("Action"); listView1.Columns.Add("Key"); foreach (ShortcutKey shortcutKey in gcMultiRow1.ShortcutKeyManager.DefaultModeList) { ListViewItem item = new ListViewItem(); item.Text = shortcutKey.Action.DisplayName; item.SubItems.Add(shortcutKey.Key.ToString()); listView1.Items.Add(item); } listView1.ResumeLayout(); |
The shortcut keys in row mode can be retrieved using the ShortcutKeyManager.RowModeList property and those in display mode can be retrieved using the ShortcutKeyManager.DisplayModeList property.
Use the ShortcutKeyManager.Register method to register the shortcut keys.
The following code starts the editing of the current cell when the user presses the F3 key.
GcMultiRow1.ShortcutKeyManager.Register(GrapeCity.Win.MultiRow.EditingActions.BeginEdit, Keys.F3) |
gcMultiRow1.ShortcutKeyManager.Register(GrapeCity.Win.MultiRow.EditingActions.BeginEdit, Keys.F3); |
Use the ShortcutKeyManager.Unregister method to unregister the already registered keys. The shortcut keys can be deleted by deleting the action or by deleting a key.
The following code deletes the shortcut key (Ctrl+A) which by default is assigned to the SelectAll action.
GcMultiRow1.ShortcutKeyManager.Unregister(GrapeCity.Win.MultiRow.SelectionActions.SelectAll) |
gcMultiRow1.ShortcutKeyManager.Unregister(GrapeCity.Win.MultiRow.SelectionActions.SelectAll); |
The following code deletes all the actions assigned to the Tab key.
GcMultiRow1.ShortcutKeyManager.Unregister(Keys.Tab) |
gcMultiRow1.ShortcutKeyManager.Unregister(Keys.Tab); |
You can create actions and assign them to the shortcut keys. To create actions for shortcut keys, create a class that implements the IAction interface.
The following code shows the current cell's information when the user presses the F3 key.
Imports GrapeCity.Win.MultiRow Public Class MyAction Implements IAction Public Function CanExecute(ByVal target As GcMultiRow) As Boolean Implements IAction.CanExecute Return True End Function Public ReadOnly Property DisplayName() As String Implements IAction.DisplayName Get Return Me.ToString() End Get End Property Public Sub Execute(ByVal target As GcMultiRow) Implements IAction.Execute MessageBox.Show(target.CurrentCellPosition.ToString()) End Sub End Class GcMultiRow1.ShortcutKeyManager.Register(New MyAction(), Keys.F3) |
using GrapeCity.Win.MultiRow; public class MyAction : IAction { public bool CanExecute(GcMultiRow target) { return true; } public string DisplayName { get { return this.ToString(); } } public void Execute(GcMultiRow target) { MessageBox.Show(target.CurrentCellPosition.ToString()); } } gcMultiRow1.ShortcutKeyManager.Register(new MyAction(), Keys.F3); |
You can also directly execute the actions of the shortcut keys. The execution of the action is treated as a user operation.
The following code selects all the cells of the GcMultiRow control.
GrapeCity.Win.MultiRow.SelectionActions.SelectAll.Execute(GcMultiRow1) |
GrapeCity.Win.MultiRow.SelectionActions.SelectAll.Execute(gcMultiRow1); |
You can change the settings for the shortcut keys for each mode in the dialog shown below, by pressing the ellipsis in the GcMultiRow.ShortcutKeyManager property in the Properties window.
You can set user-defined custom actions using the Shortcut Keys setting dialog. Use the following steps to set user-defined custom actions.
You can assign your own default shortcut keys for the user-defined default GcMultiRow control using the InitialShortcutKeyManager property.
Attention
|
The following code changes the default shortcut key for the right key of the user-defined GcMultiRow control.
Imports System.Windows.Forms Imports GrapeCity.Win.MultiRow Public Class MyGcMultiRow Inherits GcMultiRow Public Sub New() InitializeCustomGrid() End Sub Private Sub InitializeCustomGrid() Me.InitialShortcutKeyManager.Unregister(GrapeCity.Win.MultiRow.ViewMode.Row, Keys.Right) Me.InitialShortcutKeyManager.DefaultModeList.Add(New GrapeCity.Win.MultiRow.ShortcutKey _ (GrapeCity.Win.MultiRow.SelectionActions.MoveToNextCellInRow, System.Windows.Forms.Keys.Right)) End Sub End Class |
using System.Windows.Forms; using GrapeCity.Win.MultiRow; public class MyGcMultiRow : GcMultiRow { public MyGcMultiRow() { this.InitialShortcutKeyManager.Unregister(GrapeCity.Win.MultiRow.ViewMode.Default, Keys.Right); this.InitialShortcutKeyManager.DefaultModeList.Add(new GrapeCity.Win.MultiRow.ShortcutKey(((GrapeCity.Win.MultiRow.Action) (GrapeCity.Win.MultiRow.SelectionActions.MoveToNextCellInRow)), System.Windows.Forms.Keys.Right)); } } |