GrapeCity.Xaml.SpreadSheet.UI
SpreadAction Delegate
ExampleExample 


GrapeCity.Xaml.SpreadSheet.UI Namespace : SpreadAction Delegate
The object to do the action on.
The ActionEventArgs instance that contains the action event data.
Represents the action delegate for input maps.
Syntax
'Declaration
 
Public Delegate Sub SpreadAction( _
   ByVal sender As Object, _
   ByVal e As ActionEventArgs _
) 
'Usage
 
Dim instance As New SpreadAction(AddressOf HandlerMethod)
public delegate void SpreadAction( 
   object sender,
   ActionEventArgs e
)

Parameters

sender
The object to do the action on.
e
The ActionEventArgs instance that contains the action event data.
Example
This example maps keys to actions.
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
See Also

Reference

SpreadAction Members
GrapeCity.Xaml.SpreadSheet.UI Namespace