博客
关于我
winform程序C#控制tab和enter按键跳转方式横向竖向任意方式跳datagirdview
阅读量:537 次
发布时间:2019-03-08

本文共 959 字,大约阅读时间需要 3 分钟。

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)

{
// 判断是否按下Enter键且当前Cell不为空
if (keyData == Keys.Enter && this.dataGridView1.CurrentCell != null)
{
// Jump to next cell when Enter is pressed
int columnIndex = dataGridView1.CurrentCell.ColumnIndex;

if (columnIndex == 6)      {          // Check if it's the last row to avoid out-of-bounds          if (dataGridView1.CurrentCell.RowIndex + 1 == dataGridView1.Rows.Count)          {              return true;          }          // Move focus to the next cell in the same row          dataGridView1.CurrentCell = dataGridView1[2, dataGridView1.CurrentCell.RowIndex + 1];      }      // HandleTab key logic for other columns      if (columnIndex == 7)      {          return base.ProcessCmdKey(ref msg, keyData);      }      // Send Tab key for other columns      SendKeys.Send("{Tab}");      return true;  }  // Default handling for other keys  return base.ProcessCmdKey(ref msg, keyData);

}

转载地址:http://qgtiz.baihongyu.com/

你可能感兴趣的文章
MySQL执行计划解读
查看>>
mysql执行顺序与索引算法
查看>>
mysql批量update优化_Mysql中,21个写SQL的好习惯,你值得拥有呀
查看>>
mysql批量update操作时出现锁表
查看>>
MYSQL批量UPDATE的两种方式
查看>>
mysql批量修改字段名(列名)
查看>>
mysql技能梳理
查看>>
MySQL报Got an error reading communication packets错
查看>>
Mysql报错Can‘t create/write to file ‘/tmp/#sql_3a8_0.MYD‘ (Errcode: 28 - No space left on device)
查看>>
MySql报错Deadlock found when trying to get lock; try restarting transaction 的问题解决
查看>>
MySQL报错ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘
查看>>
Mysql报错Packet for query is too large问题解决
查看>>
mysql报错级别_更改MySQL日志错误级别记录非法登陆(Access denied)
查看>>
Mysql报错:too many connections
查看>>
MySQL报错:无法启动MySQL服务
查看>>
mysql排序查询
查看>>
Mysql插入数据从指定选项中随机选择、插入时间从指定范围随机生成、Navicat使用存储过程模拟插入测试数据
查看>>
MYSQL搜索引擎
查看>>
mysql操作数据表的命令_MySQL数据表操作命令
查看>>
MySQL支持的事务隔离级别,以及悲观锁和乐观锁的原理和应用场景?
查看>>