Link to home
Start Free TrialLog in
Avatar of alungwyther
alungwyther

asked on

Skip a cell on TAB in datagridview

Hi

I need to skip a cell, that is read only, when the user presses the Tab key.
I have tried the following code to skip over column 2

  Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean

        Select Case keyData
            Case Keys.Tab
                If grdHSE.CurrentCell.ColumnIndex = 1 Then
                    grdHSE.CurrentCell = grdHSE(3, grdHSE.CurrentCell.RowIndex)
                End If
        End Select
    End Function

but it skips to column 4 not 3.

All help much appreciated.

Best Regards
Alun Gwyther
Avatar of newyuppie
newyuppie
Flag of Ecuador image

try setting the StandardTab property of the Datagridview to TRUE (and remove the manual key processing)
Avatar of alungwyther
alungwyther

ASKER

Hi

Thanks for the reply.

If I do that then the focus goes to the next control in the tab order on the form.

Best Regards
Alun Gwyther
what i normally do is onkeypress
if e.keycode=tab then
sendkeys.send("{RIGHT}")
end if

this gets me to where i want to be
ASKER CERTIFIED SOLUTION
Avatar of Sancler
Sancler

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Roger

Many thanks, that did the trick.

Alun