DB Grid Basic question

I have a DBGrid, very basic question.

When using the tab to move between columns, I have to press tab twice if entering a new Value.  The first time appears to set the value into the column and the next tab moves me to the next column.  Is there a way around this?

Also, When reaching the last column, is it wise to immediately start a new row.  Or is it more work than it's worth.  Currently, upon leaving the last column in the new row, the focus switches to my exit button.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Okay... I'm going to attempt to answer your question, though I don't actually use the VB version of DBGrid.

The code below should take care of your problem with needed to press <TAB> twice:

Private Sub DBGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
    Static blnRecursive As Boolean

    If blnRecursive = False Then
        If KeyCode = 9 Then
            If DBGrid1.CurrentCellModified = True Then
                blnRecursive = True
                KeyCode = 0
                SendKeys "{TAB}{TAB}"
                blnRecursive = False
            End If
        End If
    End If
End Sub

In response to starting a new row when tabbing past the last column, my response would be "yes" - maybe.  It really depends upon what you are doing.  If you allow your end user to actually create a new record, by all means.  If it won't offend your software's standards, I find that the functionality is great.  Nothing is worse in data entry than to have to stop and use your mouse to do something.

In order to tab straight to a new row upon leaving the last row, make sure you set your WrapCellPointer property to True, and make sure that the TabAction property is set to 2 - Grid Navigation.

Hopefully this helped a little.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Once in a column/cell you can actually start typing the new value, pressing <Enter> to accept the value & then <tab> to move to next.  

To go to the next row at end of columns, it is simply a couple of dbgrdnavigation settings in the grid property.  I've found it is simply an end-user preference that determines which way I set it.

Hope this helps,
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.