对Datagridview 的事件重写!

zhengyongxianglove 2008-06-30 04:12:26
因为Datagridview控件 当回车或TAB事件后,(在数据不合法的情况下)我想让焦点停留在原地继续输入,但我没找到方法
我不知道是没有方法,还是什么。
所以我想到了重写事件。
...全文
113 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
firein 2008-07-01
  • 打赏
  • 举报
回复

Private Sub DataGridView1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGridView1.KeyDown

If e.KeyData = Keys.Enter OrElse e.KeyData = Keys.Tab Then
e.Handled = True
End If

End Sub
fishidea 2008-07-01
  • 打赏
  • 举报
回复
楼上的楼上正解...
神之泪花 2008-07-01
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 iwqfeng 的回复:]
VB.NET code

Protected Overloads Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
If TypeOf ActiveControl Is System.Windows.Forms.DataGridViewTextBoxEditingControl Then
If keyData = Keys.Enter Then
.
.'这里面写需要的事件
.
End If
End If
[/Quote]
iwqfeng 2008-07-01
  • 打赏
  • 举报
回复


Protected Overloads Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
If TypeOf ActiveControl Is System.Windows.Forms.DataGridViewTextBoxEditingControl Then
If keyData = Keys.Enter Then
.
.'这里面写需要的事件
Return True
End If
End If
End Function
iwqfeng 2008-07-01
  • 打赏
  • 举报
回复


Protected Overloads Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
If TypeOf ActiveControl Is System.Windows.Forms.DataGridViewTextBoxEditingControl Then
If keyData = Keys.Enter Then
.
.'这里面写需要的事件
.
End If
End If
hc8112_boy 2008-06-30
  • 打赏
  • 举报
回复
重写 Processcmdkey
GT7466 2008-06-30
  • 打赏
  • 举报
回复
用javaScript捕捉 用户按回车或TAB

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧