GrapeCity.Xaml.SpreadSheet.UI Namespace > SpreadActions Class : NavigationLeft Method |
'Declaration Public Shared Sub NavigationLeft( _ ByVal sender As Object, _ ByVal e As ActionEventArgs _ )
'Usage Dim sender As Object Dim e As ActionEventArgs SpreadActions.NavigationLeft(sender, e)
public static void NavigationLeft( object sender, ActionEventArgs e )
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)); }
Private Sub OnInsertSumFormula(sender As Object, e As GrapeCity.Xaml.SpreadSheet.UI.ActionEventArgs) Dim sheet As GrapeCity.Xaml.SpreadSheet.Data.Worksheet = gcSpreadSheet1.ActiveSheet Dim r As Integer = sheet.ActiveRowIndex Dim c As Integer = sheet.ActiveColumnIndex If r > 0 Then Dim rStart As Integer = r - 1 While rStart > 0 Dim val As Object = sheet.Cells(rStart, c).Value If TypeOf val Is Double OrElse TypeOf val Is Single OrElse TypeOf val Is Long OrElse TypeOf val Is Integer OrElse TypeOf val Is Short OrElse TypeOf val Is Byte OrElse (val IsNot Nothing) Then rStart -= 1 End If End While '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. Dim formula As String = "SUM(" & sheet.Cells(rStart, c, r - 1, c).ToString() & ")" sheet.Cells(r, c).Formula = formula gcSpreadSheet1.View.StartCellEditing() End If End Sub Private Sub MainPage_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded Dim keyMap As Dictionary(Of GrapeCity.Xaml.SpreadSheet.UI.KeyStroke, GrapeCity.Xaml.SpreadSheet.UI.SpreadAction) = gcSpreadSheet1.View.KeyMap keyMap.Add(New GrapeCity.Xaml.SpreadSheet.UI.KeyStroke(DirectCast(187, Windows.System.VirtualKey), Windows.System.VirtualKeyModifiers.Menu), New GrapeCity.Xaml.SpreadSheet.UI.SpreadAction(AddressOf OnInsertSumFormula)) keyMap.Add(New GrapeCity.Xaml.SpreadSheet.UI.KeyStroke(Windows.System.VirtualKey.B, Windows.System.VirtualKeyModifiers.Menu), New GrapeCity.Xaml.SpreadSheet.UI.SpreadAction(AddressOf 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(AddressOf GrapeCity.Xaml.SpreadSheet.UI.SpreadActions.Clear)) End Sub
Target Platforms: Windows Server 2012, Windows RT