Jump to content

[VB.net] DataGridView saltar colunas

Recommended Posts


Boas ppl eu tenho uma datagridview e quero que ao clicar no TAB ele salte para a célula 4, mas se andar com as setas fica normal, eu fiz isto:

Private Sub DataGridView1_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles dgvContactos.EditingControlShowing
        Dim EditingTxtBox As TextBox = CType(e.Control, TextBox)
        AddHandler EditingTxtBox.KeyDown, AddressOf dgvContactos_EditingModeKeyDown
    End Sub

    Private Sub dgvContactos_EditingModeKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
    End Sub

Isto funciona mas não captura o tab estou perdido.


Share this post

Link to post
Share on other sites

Olá Laboss.

Exprimenta este código:

Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
        ' Verifica se a tecla pressionada foi a ENTER e se a célula está a ser editada
        If keyData = Keys.Enter And Me.'nome da tabela'DataGridView.IsCurrentCellInEditMode Then
            ' Executa um TAB
            ' Ignora a tecla pressionada
            Return True
            ' Executa o processo normal
            Return MyBase.ProcessCmdKey(msg, keyData)
        End If
    End Function

Boa sorte,


André Machado

André Machadohttp://andremachado.pt.vu

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.