GrapeCity MultiRow Windows Forms Documentation
ShortcutKeyManager Property
Example 


Gets or sets the ShortcutKey manager of the GcMultiRow control.
Syntax
<SRCategoryAttribute("Behavior")>
<DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)>
<EditorAttribute(EditorBaseTypeName="System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", EditorTypeName="GrapeCity.Win.MultiRow.Design.ShortcutKeyManagerEditor, GrapeCity.Win.MultiRow, Version=7.20.20141.0, Culture=neutral, PublicKeyToken=0f7a722ee3c2bdd9")>
<SRDescriptionAttribute("Indicates the ShortcutKey manager of the GcMultiRow control.")>
<MergablePropertyAttribute(False)>
Public Property ShortcutKeyManager As ShortcutKeyManager
Dim instance As GcMultiRow
Dim value As ShortcutKeyManager
 
instance.ShortcutKeyManager = value
 
value = instance.ShortcutKeyManager
[SRCategory("Behavior")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[Editor(EditorBaseTypeName="System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", EditorTypeName="GrapeCity.Win.MultiRow.Design.ShortcutKeyManagerEditor, GrapeCity.Win.MultiRow, Version=7.20.20141.0, Culture=neutral, PublicKeyToken=0f7a722ee3c2bdd9")]
[SRDescription("Indicates the ShortcutKey manager of the GcMultiRow control.")]
[MergableProperty(false)]
public ShortcutKeyManager ShortcutKeyManager {get; set;}

Property Value

A ShortcutKeyManager that represents the GcMultiRow control ShortcutKey manager.
Remarks

The GcMultiRow control provides many default ShortcutKeys to help you execute certain Actions conveniently. By default, once the GcMultiRow control is created, the default ShortcutKeys are registered. You can use the ShortcutKeyManager to manage these ShortcutKeys. You can use the ShortcutKeyManager.Register method to add a new ShortcutKey to GcMultiRow, or use the ShortcutKeyManager.Unregister to delete a ShortcutKey.

You can customize an Action and specify the keys, then register this ShortcutKey to GcMultiRow.

Example
The following code example shows how to manage shortcut key settings. The example shows how to change a key's action, and how to customize your own action.
GcMultiRow gcMultiRow1 = new GcMultiRow();

public ShortcutKeysDemo()
{
    this.Text = "Customize ShortcutKey  (Enter key, Ctrl+Shift+C)";

    gcMultiRow1.Dock = DockStyle.Fill;
    this.Controls.Add(gcMultiRow1);
    this.Load += new EventHandler(Form1_Load);
}


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);
        }
    }
}
Class ShortcutKeysDemo
    Inherits Form
    Private gcMultiRow1 As New GcMultiRow()

    Public Sub New()
        Me.Text = "Customize ShortcutKey  (Enter key, Ctrl+Shift+C)"
        gcMultiRow1.Dock = DockStyle.Fill
        Me.Controls.Add(gcMultiRow1)
    End Sub

    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

GcMultiRow Class
GcMultiRow Members
ShortcutKeyManager Class
IAction Interface
Action Class
ShortcutKey Structure
ShortcutKeyManager.Register
ShortcutKeyManager.Unregister

 

 


Copyright © GrapeCity, inc. All rights reserved.