我有datagridview有4列,前三列是texbox,第四是命令按钮。我想覆盖datagridview中的回车键,以便它将焦点设置到下一列而不是下一行?当我到达texbox第3列时,它会跳过命令按钮并转到下一行,这是我的代码
Class MyDataGridView
Inherits DataGridView
Protected Overloads Overrides Function ProcessDialogKey(ByVal keyData As Keys) As Boolean
If keyData = Keys.Enter Then
MyBase.ProcessTabKey(Keys.Tab)
Return True
End If
Return MyBase.ProcessDialogKey(keyData)
End Function
Protected Overloads Overrides Function ProcessDataGridViewKey(ByVal e As KeyEventArgs) As Boolean
If e.KeyCode = Keys.Enter Then
MyBase.ProcessTabKey(Keys.Tab)
Return True
End If
Return MyBase.ProcessDataGridViewKey(e)
End Function
End Class
此代码工作正常,但唯一的问题是它也是焦点命令按钮我想跳过命令按钮。 bcz命令按钮是删除记录按钮
答案 0 :(得分:1)
我的问题已被解决了 这是解决方案
Private Sub MyDataGridView1_CurrentCellChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyDataGridView1.CurrentCellChanged
If MyDataGridView1.CurrentCellAddress.X = 8 Then
SendKeys.Send("{TAB}")
End If
End Sub