GrapeCity MultiRow Windows Forms Documentation
IAction Interface
Members  Example 


Defines an action that is bound to a specific key or key combination in GcMultiRow.
Syntax
<TypeConverterAttribute("GrapeCity.Win.MultiRow.Design.ActionConverter, GrapeCity.Win.MultiRow, Version=7.20.20141.0, Culture=neutral, PublicKeyToken=0f7a722ee3c2bdd9")>
Public Interface IAction 
Dim instance As IAction
[TypeConverter("GrapeCity.Win.MultiRow.Design.ActionConverter, GrapeCity.Win.MultiRow, Version=7.20.20141.0, Culture=neutral, PublicKeyToken=0f7a722ee3c2bdd9")]
public interface IAction 
Remarks

You can use the existing actions in SelectionActions, EditingActions, ComponentActions, or ScrollActions. You can also write your own special action by implementing this interface.

An Action is an operation that is performed by a GcMultiRow control. Typically, an Action is appointed by a special key set using a ShortcutKey. When the key set is pressed, the Action is executed automatically. An Action can also used to perform a special operation by using the Execute method in code.

Example
The following code example shows how to manage GcMultiRow control shortcut key settings. The example shows how to change a key's action and how to customize your own action. This code example is part of a larger example provided for the GcMultiRow.ShortcutKeyManager property.
void Form1_Load(object sender, EventArgs e)
        {
            gcMultiRow1.Template = Template.Default;
            gcMultiRow1.RowCount = 5;

            // Register another action to an existing key. Unregister old key first.
            this.gcMultiRow1.ShortcutKeyManager.Unregister(Keys.Enter);
            // Register to new action.
            this.gcMultiRow1.ShortcutKeyManager.Register(new EditThenMoveNextAction(), Keys.Enter);

            // Register an action list. Select all first, and then, copy.
            this.gcMultiRow1.ShortcutKeyManager.Register(new ActionList(SelectionActions.SelectAll, EditingActions.Copy), Keys.Control | Keys.Shift | Keys.C);
        }

        class EditThenMoveNextAction : Action
        {
            public override bool CanExecute(GcMultiRow target)
            {
                return true;
            }

            protected override void OnExecute(GcMultiRow target)
            {
                if (target.IsCurrentCellInEditMode == false && EditingActions.BeginEdit.CanExecute(target))
                {
                    EditingActions.BeginEdit.Execute(target);
                }
                else
                {
                    SelectionActions.MoveToNextCell.Execute(target);
                }
            }
        }
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        gcMultiRow1.Template = Template.Default
        gcMultiRow1.RowCount = 5

        ' Register another action to an existing key. Unregister old key first.
        Me.gcMultiRow1.ShortcutKeyManager.Unregister(Keys.Enter)
        ' Register to new action.
        Me.gcMultiRow1.ShortcutKeyManager.Register(New EditThenMoveNextAction(), Keys.Enter)

        ' Register an action list. Select all first, and then, copy.
        Me.gcMultiRow1.ShortcutKeyManager.Register(New ActionList(SelectionActions.SelectAll, EditingActions.Copy), Keys.Control Or Keys.Shift Or Keys.C)
    End Sub

    Private Class EditThenMoveNextAction
        Inherits Action
        Public Overloads Overrides Function CanExecute(ByVal target As GcMultiRow) As Boolean
            Return True
        End Function

        Protected Overloads Overrides Sub OnExecute(ByVal target As GcMultiRow)
            If target.IsCurrentCellInEditMode = False AndAlso EditingActions.BeginEdit.CanExecute(target) Then
                EditingActions.BeginEdit.Execute(target)
            Else
                SelectionActions.MoveToNextCell.Execute(target)
            End If
        End Sub
    End Class
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

IAction Members
GrapeCity.Win.MultiRow Namespace
Action Class
ActionList Class
SelectionActions Class
EditingActions Class
ComponentActions Class
ScrollActions Class
ShortcutKey Structure
ShortcutKeyManager Class

 

 


Copyright © GrapeCity, inc. All rights reserved.