0

嗨,我有 4 列的 datagridview,前三列是 texbox,第四列是命令按钮。我想覆盖 datagridview 中的 enter 键,以便它将焦点设置到下一列而不是下一行?当我到达 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 命令按钮是删除记录按钮

4

1 回答 1

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
于 2013-07-01T10:57:31.477 回答