找回密码
 立即注册

QQ登录

只需一步,快速开始

sakeryu

初级会员

34

主题

122

帖子

322

积分

初级会员

积分
322

活字格认证

sakeryu
初级会员   /  发表于:2013-4-12 15:22  /   查看:11743  /  回复:12
用的spread6.0
在excel中,输入数字,回车,焦点自动到了下一个单元格,直接敲入数字就行。

现在用spread是输入数字,回车,(等于确认了输入),焦点还在当前单元格,需要再次回车,焦点才会跳到下一个单元格,才能输入数字。。。好多用户习惯excel,敲完回车就继续输入数字,结果搞了半天发现一直在同一个单元格内反复输入数字。

请问要实现和excel一样的方式应该用什么属性??怎么弄?谢谢。

12 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2013-4-12 16:23:00
沙发
回复 1楼sakeryu的帖子

这是很常见的用例,请使用以下代码测试:

  1. // Create an InputMap object.

  2. FarPoint.Win.Spread.InputMap inputmap1;// Assign the InputMap object to the existing map.inputmap1 = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused);

  3. // Map the Enter key.

  4. inputmap1.Put(new FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextRow);

  5. // Create another InputMap object.

  6. FarPoint.Win.Spread.InputMap inputmap2;

  7. // Assign this InputMap object to the existing map.

  8. inputmap2 = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused);

  9. // Map the Enter key.

  10. inputmap2.Put(new FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextRow);

复制代码
回复 使用道具 举报
sakeryu
初级会员   /  发表于:2013-4-15 11:18:00
板凳
我也遇到同样问题,但是在最后一列时:
(如果是最后一行,则要自动增加行)焦点自动移到下一行的第一列,如何处理。
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-4-15 16:02:00
地板
回复 3楼sakeryu的帖子

修正一下二楼中 代码:

  1. private void Form1_Load(object sender, EventArgs e)
  2.         {
  3.             FarPoint.Win.Spread.InputMap inputmap1 = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused); // Assign the InputMap object to the existing map.inputmap1 = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused);

  4.             // Map the Enter key.

  5.             inputmap1.Put(new FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextRow);

  6.             // Create another InputMap object.

  7.             FarPoint.Win.Spread.InputMap inputmap2;

  8.             // Assign this InputMap object to the existing map.

  9.             inputmap2 = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused);

  10.             // Map the Enter key.

  11.             inputmap2.Put(new FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextRow);
  12.         }
复制代码
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-4-15 16:03:00
5#
回复 3楼sakeryu的帖子

可以在自动增加行代码中,通过 SetActiveCell 到该行最后一列
回复 使用道具 举报
sakeryu
初级会员   /  发表于:2013-4-16 13:00:00
6#
这个也搞定了。谢谢
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-4-16 17:46:00
7#
回复 使用道具 举报
silenceyy2010
高级会员   /  发表于:2013-11-1 16:02:00
8#
我有问题要请教~~
现在我有一个fpspread表格,3列,20行,
我想要一行一行的输入数据,回车自动跳到下一个单元格。
在上边的代码基础上改了一下:
FarPoint.Win.Spread.InputMap inputmap1 = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused);
// Assign the InputMap object to the existing
// Map the Enter key.
inputmap1.Put(new FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextColumn);
// Create another InputMap object.
FarPoint.Win.Spread.InputMap inputmap2=fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused);
// Map the Enter key.
inputmap2.Put(new FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextRowFirstColumn);

这样改之后,有一个问题,单元格移动到每行第三个之后,要回车两次才能跳转到下一行,有没有办法解决呢?
谢谢!
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-11-1 18:24:00
9#
回复 8楼silenceyy2010的帖子

你好,
这个 case 无法完全通过 InputMap 实现。可以添加以下代码:

  1. void fpSpread1_EditModeOff(object sender, EventArgs e)
  2.         {
  3.             if (this.fpSpread1.Sheets[0].ActiveColumnIndex == 2)
  4.             {
  5.                 this.fpSpread1.Sheets[0].SetActiveCell(this.fpSpread1.Sheets[0].ActiveRowIndex + 1, 0);
  6.             }
  7.         }
复制代码
回复 使用道具 举报
silenceyy2010
高级会员   /  发表于:2013-11-4 12:57:00
10#
好的,谢谢!
已搞定!
回复 使用道具 举报
12下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部