Spread WinRT Documentation > Developer's Guide > Managing the User Interface > Using Input Mapping |
You can change the keyboard keys that are used to trigger built-in actions to other keys. Actions include navigation, selection, cut, copy, paste, clear, undo, and redo.
There is a complete list of actions in the SpreadActions class.
Use the Add or Remove methods in the key map collection to add or remove keys.
This example maps the Alt and Equal keys to an action.
CS |
Copy Code |
---|---|
private void OnInsertSumFormula(object sender, GrapeCity.Xaml.SpreadSheet.UI.ActionEventArgs e) { GrapeCity.Xaml.SpreadSheet.Data.Worksheet sheet = gcSpreadSheet1.ActiveSheet; int r = sheet.ActiveRowIndex; int c = sheet.ActiveColumnIndex; if (r > 0) { int rStart = r - 1; while (rStart > 0) { object val = sheet.Cells[rStart, c].Value; if (val is double || val is float || val is long || val is int || val is short || val is byte || (val != null)) rStart -= 1; } //Type numbers in a few cells in a column and type Alt + equal in the cell below them. //Hit enter to see the formula update. string formula = "SUM(" + sheet.Cells[rStart, c, r - 1, c].ToString() + ")"; sheet.Cells[r, c].Formula = formula; gcSpreadSheet1.View.StartCellEditing(); } } private void Grid_Loaded_1(object sender, RoutedEventArgs e) { Dictionary<GrapeCity.Xaml.SpreadSheet.UI.KeyStroke, GrapeCity.Xaml.SpreadSheet.UI.SpreadAction> keyMap = gcSpreadSheet1.View.KeyMap; keyMap.Add(new GrapeCity.Xaml.SpreadSheet.UI.KeyStroke((Windows.System.VirtualKey)187, Windows.System.VirtualKeyModifiers.Menu), new GrapeCity.Xaml.SpreadSheet.UI.SpreadAction(OnInsertSumFormula)); keyMap.Add(new GrapeCity.Xaml.SpreadSheet.UI.KeyStroke(Windows.System.VirtualKey.B, Windows.System.VirtualKeyModifiers.Menu), new GrapeCity.Xaml.SpreadSheet.UI.SpreadAction(GrapeCity.Xaml.SpreadSheet.UI.SpreadActions.NavigationLeft)); keyMap.Add(new GrapeCity.Xaml.SpreadSheet.UI.KeyStroke(Windows.System.VirtualKey.A, Windows.System.VirtualKeyModifiers.Menu), new GrapeCity.Xaml.SpreadSheet.UI.SpreadAction(GrapeCity.Xaml.SpreadSheet.UI.SpreadActions.Clear)); } |
VB |
Copy Code |
---|---|
private void OnInsertSumFormula(object sender, GrapeCity.Xaml.SpreadSheet.UI.ActionEventArgs e) { GrapeCity.Xaml.SpreadSheet.Data.Worksheet sheet = gcSpreadSheet1.ActiveSheet; int r = sheet.ActiveRowIndex; int c = sheet.ActiveColumnIndex; if (r > 0) { int rStart = r - 1; while (rStart > 0) { object val = sheet.Cells[rStart, c].Value; if (val is double || val is float || val is long || val is int || val is short || val is byte || (val != null)) rStart -= 1; } //Type numbers in a few cells in a column and type Alt + equal in the cell below them. //Hit enter to see the formula update. string formula = "SUM(" + sheet.Cells[rStart, c, r - 1, c].ToString() + ")"; sheet.Cells[r, c].Formula = formula; gcSpreadSheet1.View.StartCellEditing(); } } private void Grid_Loaded_1(object sender, RoutedEventArgs e) { Dictionary<GrapeCity.Xaml.SpreadSheet.UI.KeyStroke, GrapeCity.Xaml.SpreadSheet.UI.SpreadAction> keyMap = gcSpreadSheet1.View.KeyMap; keyMap.Add(new GrapeCity.Xaml.SpreadSheet.UI.KeyStroke((Windows.System.VirtualKey)187, Windows.System.VirtualKeyModifiers.Menu), new GrapeCity.Xaml.SpreadSheet.UI.SpreadAction(OnInsertSumFormula)); keyMap.Add(new GrapeCity.Xaml.SpreadSheet.UI.KeyStroke(Windows.System.VirtualKey.B, Windows.System.VirtualKeyModifiers.Menu), new GrapeCity.Xaml.SpreadSheet.UI.SpreadAction(GrapeCity.Xaml.SpreadSheet.UI.SpreadActions.NavigationLeft)); keyMap.Add(new GrapeCity.Xaml.SpreadSheet.UI.KeyStroke(Windows.System.VirtualKey.A, Windows.System.VirtualKeyModifiers.Menu), new GrapeCity.Xaml.SpreadSheet.UI.SpreadAction(GrapeCity.Xaml.SpreadSheet.UI.SpreadActions.Clear)); } |