先定义两个自定义Action,代码如下
- class EditAndMoveLeft : GrapeCity.Win.MultiRow.Action
- {
- public override bool CanExecute(GcMultiRow target)
- {
- if(target.IsCurrentCellInEditMode)
- {
- return SelectionActions.MoveLeft.CanExecute(target);
- }
- else
- {
- return EditingActions.BeginEdit.CanExecute(target);
- }
- }
- protected override void OnExecute(GcMultiRow target)
- {
- if (target.IsCurrentCellInEditMode)
- {
- SelectionActions.MoveLeft.Execute(target);
- }
- else
- {
- EditingActions.BeginEdit.Execute(target);
- }
- }
- }
- class EditAndMoveRight : GrapeCity.Win.MultiRow.Action
- {
- public override bool CanExecute(GcMultiRow target)
- {
- if (target.IsCurrentCellInEditMode)
- {
- return SelectionActions.MoveRight.CanExecute(target);
- }
- else
- {
- return EditingActions.BeginEdit.CanExecute(target);
- }
- }
- protected override void OnExecute(GcMultiRow target)
- {
- if (target.IsCurrentCellInEditMode)
- {
- SelectionActions.MoveRight.Execute(target);
- }
- else
- {
- EditingActions.BeginEdit.Execute(target);
- }
- }
- }
复制代码
然后把自定义Action注册给GcMultiRow
- this.gcMultiRow1.ShortcutKeyManager.Register(new EditAndMoveLeft(), Keys.Left);
- this.gcMultiRow1.ShortcutKeyManager.Register(new EditAndMoveRight(), Keys.Right);
复制代码 |