博客
关于我
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/

你可能感兴趣的文章
PXC搭建MySQL高可用集群
查看>>
PXE + Kickstart 服务器批量安装Linux系统
查看>>
PXE+HTTP+TFTP+Kickstart实现无人值守部署centos6.10
查看>>
pxe实现linux的自动安装
查看>>
py 的 第 19 天
查看>>
Py-Bitcoin 项目使用教程
查看>>
Pytorch 图像增强 实现翻转裁剪色调等 附代码(全)
查看>>
pyautogui模拟鼠标拖动选中文字的基本知识(附Demo)
查看>>
pyautogui的基本介绍和使用
查看>>
PyCharm - 社区版是否能够突出显示 css/javascript?
查看>>
PyCharm 2018.3.5 RC 发布,原生 SSH 支持
查看>>
PyCharm 3.1 在索引期间永远挂起并且无法使用
查看>>
Pycharm Pro 2018.2 汉化专业激活破解
查看>>
PyCharm vs VSCode,是时候改变你的 IDE 了!
查看>>
PyCharm 中,“新建”(New)和“新建项目”(New Project)-ChatGPT4o作答
查看>>
PyCharm 代码编辑与调试运行详解
查看>>
Pycharm 出现 instantitaing tests 以及test session starts 的解决方法
查看>>
pytorch 固定随机种子
查看>>
Pycharm 对容器中的 Python 程序断点远程调试
查看>>
Pycharm 常用快捷键大全【快查字典版】
查看>>