禁用 datagridview 中的默认 Enter/Return 键行为 [英] disable the default Enter/Return key behavior in a datagridview

查看:34
本文介绍了禁用 datagridview 中的默认 Enter/Return 键行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 vb.net datagridview 中,默认的 Enter/Return 键行为是移动到下一行,是否有一种快速简便的方法可以避免这种情况.

In vb.net datagridview the default Enter/Return key behavior is to move to the next row is there a quick and easy way to avoid that.

欢迎任何建议

推荐答案

你可以在gridview的key down事件中尝试这样的事情

You can try something like this in the gridview key down event

Private Sub DataGridView1_Keydown (...) Handlers DataGridView1.KeyDown
   If e.KeyCode = Keys.Enter Then
       ' Your code here
       e.SuppressKeyPress = True
  End If 
End Sub

另一种选择是创建自定义网格视图控件

Another option would be to create a custom grid view control

DataGridView.ProcessDataGridViewKey 方法

这篇关于禁用 datagridview 中的默认 Enter/Return 键行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆