GrapeCity.Win.MultiRow.v80 アセンブリ > GrapeCity.Win.MultiRow 名前空間 > GcMultiRow クラス : ShortcutKeyManager プロパティ |
Public Property ShortcutKeyManager As ShortcutKeyManager
public ShortcutKeyManager ShortcutKeyManager {get; set;}
GcMultiRowには、いくつかのActionを便利に実行するために役立つ既定のShortcutKeyが多数用意されています。既定では、GcMultiRowコントロールを作成すると、既定のShortcutKeyが登録されます。これらのShortcutKeyは、ShortcutKeyManagerを使用して管理できます。たとえば、ShortcutKeyManager.Registerメソッドを使用して、新しいShortcutKeyをGcMultiRowに追加できます。また、ShortcutKeyManager.Unregisterを使用してShortcutKeyを削除することもできます。
Actionをカスタマイズしてキーを指定してから、このShortcutKeyをGcMultiRowに追加します。
using System; using System.Windows.Forms; namespace GrapeCity.Win.MultiRow.SampleCode { class ShortcutKeysDemo : Form { 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 a existent 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); } } } [STAThreadAttribute()] public static void Main() { Application.EnableVisualStyles(); Application.Run(new ShortcutKeysDemo()); } } }
Imports System Imports System.Windows.Forms Imports GrapeCity.Win.MultiRow 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 a existent 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 <STAThreadAttribute()> _ Public Shared Sub Main() Application.EnableVisualStyles() Application.Run(New ShortcutKeysDemo()) End Sub End Class