代码如下:
- public class MyTabAction : GrapeCity.Win.MultiRow.Action
- {
- public override bool CanExecute(GcMultiRow target)
- {
- return SelectionActions.MoveToLastCell.CanExecute(target)
- && SelectionActions.MoveToNextCell.CanExecute(target);
- }
- protected override void OnExecute(GcMultiRow target)
- {
- SelectionActions.MoveToNextCell.Execute(target);
- }
- }
- public class MyShiftTabAction : GrapeCity.Win.MultiRow.Action
- {
- public override bool CanExecute(GcMultiRow target)
- {
- return SelectionActions.MoveToFirstCell.CanExecute(target)
- && SelectionActions.MoveToPreviousCell.CanExecute(target);
- }
- protected override void OnExecute(GcMultiRow target)
- {
- SelectionActions.MoveToPreviousCell.Execute(target);
- }
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- this.gcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.MoveToPreviousCell);
- this.gcMultiRow1.ShortcutKeyManager.Unregister(SelectionActions.MoveToNextCell);
- this.gcMultiRow1.ShortcutKeyManager.Register(new MyTabAction(), Keys.Tab);
- this.gcMultiRow1.ShortcutKeyManager.Register(new MyShiftTabAction(), Keys.Tab | Keys.Shift);
- }
复制代码
这段代码利用了SelectionActions.MoveToLastCell 在已经移动到最后一个Cell时 CanExecute 会返回false。 |