用过spread的朋友可能会碰到这么一种情况:
如果我的画面中有快捷键,比如说“F1”、“F2”、“F3”等等,当你的焦点在spread里边时,
你会发现你定义的那些快捷键有时候不反应,原因是焦点陷入spread里面,导致画面捕捉不到快捷键。
给个画面例子:
![](/images/cnblogs_com/yuwy/36030_070419124046.jpg)
对于以上画面中的那些快捷键(画面底部),如果焦点在spread中,就会可能导致“F3”不好用。
解决方法:
在你的画面的构造函数里边加上以下代码
FarPoint.Win.Spread.InputMap im;
//spdResult是你画面中定义的spread的名字。
//WhenFocused:焦点离开时
im = spdResult.GetInputMap(InputMapMode.WhenFocused);
//按回车键和TAB时,焦点移动到下一个单元格
im.Put(new Keystroke(Keys.Enter,Keys.None),SpreadActions.MoveToNextColumnWrap);
im.Put(new Keystroke(Keys.Tab,Keys.None),SpreadActions.MoveToNextColumnWrap);
//按→、↓、←、↑时,焦点移动
im.Put(new Keystroke(Keys.Left,Keys.None),SpreadActions.MoveToPreviousColumn);
im.Put(new Keystroke(Keys.Right,Keys.None),SpreadActions.MoveToNextColumn);
//使快捷键有效
im.Put(new Keystroke(Keys.F1,Keys.None),SpreadActions.None);
im.Put(new Keystroke(Keys.F2,Keys.None),SpreadActions.None);
im.Put(new Keystroke(Keys.F3,Keys.None),SpreadActions.None);
im.Put(new Keystroke(Keys.F8,Keys.None),SpreadActions.None);
im.Put(new Keystroke(Keys.F10,Keys.None),SpreadActions.None);
im.Put(new Keystroke(Keys.F12,Keys.None),SpreadActions.None);
//WhenAncestorOfFocused:得到焦点时
im = spdResult.GetInputMap(InputMapMode.WhenAncestorOfFocused);
im.Put(new Keystroke(Keys.Enter,Keys.None),SpreadActions.MoveToNextColumnWrap);
im.Put(new Keystroke(Keys.Tab,Keys.None),SpreadActions.MoveToNextColumnWrap);
im.Put(new Keystroke(Keys.Left,Keys.None),SpreadActions.MoveToPreviousColumn);
im.Put(new Keystroke(Keys.Right,Keys.None),SpreadActions.MoveToNextColumn);
im.Put(new Keystroke(Keys.F1,Keys.None),SpreadActions.None);
im.Put(new Keystroke(Keys.F2,Keys.None),SpreadActions.None);
im.Put(new Keystroke(Keys.F3,Keys.None),SpreadActions.None);
im.Put(new Keystroke(Keys.F8,Keys.None),SpreadActions.None);
im.Put(new Keystroke(Keys.F10,Keys.None),SpreadActions.None);
im.Put(new Keystroke(Keys.F12,Keys.None),SpreadActions.None);
-以上是网上作者做的(sunjianbo.cublog.cn)
还有解决办法在后面.
//spdResult是你画面中定义的spread的名字。
//WhenFocused:焦点离开时
im = spdResult.GetInputMap(InputMapMode.WhenFocused);
//按回车键和TAB时,焦点移动到下一个单元格
im.Put(new Keystroke(Keys.Enter,Keys.None),SpreadActions.MoveToNextColumnWrap);
im.Put(new Keystroke(Keys.Tab,Keys.None),SpreadActions.MoveToNextColumnWrap);
//按→、↓、←、↑时,焦点移动
im.Put(new Keystroke(Keys.Left,Keys.None),SpreadActions.MoveToPreviousColumn);
im.Put(new Keystroke(Keys.Right,Keys.None),SpreadActions.MoveToNextColumn);
//使快捷键有效
im.Put(new Keystroke(Keys.F1,Keys.None),SpreadActions.None);
im.Put(new Keystroke(Keys.F2,Keys.None),SpreadActions.None);
im.Put(new Keystroke(Keys.F3,Keys.None),SpreadActions.None);
im.Put(new Keystroke(Keys.F8,Keys.None),SpreadActions.None);
im.Put(new Keystroke(Keys.F10,Keys.None),SpreadActions.None);
im.Put(new Keystroke(Keys.F12,Keys.None),SpreadActions.None);
//WhenAncestorOfFocused:得到焦点时
im = spdResult.GetInputMap(InputMapMode.WhenAncestorOfFocused);
im.Put(new Keystroke(Keys.Enter,Keys.None),SpreadActions.MoveToNextColumnWrap);
im.Put(new Keystroke(Keys.Tab,Keys.None),SpreadActions.MoveToNextColumnWrap);
im.Put(new Keystroke(Keys.Left,Keys.None),SpreadActions.MoveToPreviousColumn);
im.Put(new Keystroke(Keys.Right,Keys.None),SpreadActions.MoveToNextColumn);
im.Put(new Keystroke(Keys.F1,Keys.None),SpreadActions.None);
im.Put(new Keystroke(Keys.F2,Keys.None),SpreadActions.None);
im.Put(new Keystroke(Keys.F3,Keys.None),SpreadActions.None);
im.Put(new Keystroke(Keys.F8,Keys.None),SpreadActions.None);
im.Put(new Keystroke(Keys.F10,Keys.None),SpreadActions.None);
im.Put(new Keystroke(Keys.F12,Keys.None),SpreadActions.None);
-以上是网上作者做的(sunjianbo.cublog.cn)
还有解决办法在后面.