找回密码
 立即注册

QQ登录

只需一步,快速开始

sie

初级会员

40

主题

96

帖子

314

积分

初级会员

积分
314

活字格认证

sie
初级会员   /  发表于:2014-11-17 09:36  /   查看:5621  /  回复:7
C1FlexGrid,目前在单元格上面按回车键,是直接进入编辑的
而我想实现的效果是,按回车键仅移动到下一个单元格,而不要进入编辑状态,请问能否实现呢
谢谢!

7 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2014-11-17 11:50:00
沙发
回复 1楼sie的帖子

实现代码如下:

  1.         private void Form1_Load(object sender, EventArgs e)
  2.         {
  3.             this.c1FlexGrid1.KeyPress += c1FlexGrid1_KeyPress;
  4.         }

  5.         void c1FlexGrid1_KeyPress(object sender, KeyPressEventArgs e)
  6.         {
  7.             if (e.KeyChar == '\r')
  8.             {
  9.                 e.Handled = true;
  10.                 this.c1FlexGrid1.Row += 1;
  11.             }
  12.         }
复制代码


注意添加最后一行判断,需要跳转到下一列第一行。

为了给你提供更优质的服务,请对本次服务进行评分。我们会认真对待你提出的宝贵意见,谢谢
回复 使用道具 举报
dqjia
注册会员   /  发表于:2014-11-17 13:42:00
板凳
grid.KeyActionEnter = KeyActionEnum.MoveAcross;
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2014-11-17 18:38:00
地板
回复 1楼sie的帖子

请问2#代码是否满足需求?
回复 使用道具 举报
zhangyi
初级会员   /  发表于:2017-6-8 02:09:30
5#
iceman 发表于 2014-11-17 18:38
回复 1楼sie的帖子

请问2#代码是否满足需求?

完美解决了我遇到的这个相同的问题,谢谢   iceman  
        private void grid1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
            {
                if (grid1.Row < this.grid1.Rows.Count - 1)
                {
                    e.Handled = true;
                    this.grid1.Row += 1;
                }
                else
                {
                    e.Handled = true;
                }
            }
        }
回复 使用道具 举报
zhangyi
初级会员   /  发表于:2017-6-8 02:09:35
6#
iceman 发表于 2014-11-17 18:38
回复 1楼sie的帖子

请问2#代码是否满足需求?

完美解决了我遇到的这个相同的问题,谢谢   iceman  
        private void grid1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
            {
                if (grid1.Row < this.grid1.Rows.Count - 1)
                {
                    e.Handled = true;
                    this.grid1.Row += 1;
                }
                else
                {
                    e.Handled = true;
                }
            }
        }
回复 使用道具 举报
zhangyi
初级会员   /  发表于:2017-6-8 02:09:39
7#
iceman 发表于 2014-11-17 18:38
回复 1楼sie的帖子

请问2#代码是否满足需求?

完美解决了我遇到的这个相同的问题,谢谢   iceman  
        private void grid1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
            {
                if (grid1.Row < this.grid1.Rows.Count - 1)
                {
                    e.Handled = true;
                    this.grid1.Row += 1;
                }
                else
                {
                    e.Handled = true;
                }
            }
        }
回复 使用道具 举报
JeffryLI
葡萄城公司职员   /  发表于:2017-6-8 09:37:57
8#
请点击评分,对我5分评价,谢谢!

葡萄城控件服务团队
官方网站: https://www.grapecity.com.cn/developer
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部