Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Visual Basic
Expertise: Beginner
Aug 8, 1997



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Data Entry Becomes User Friendly: Move To The Next Cell In DBGrid Std Control

When I replaced the Apex dbGrid, with the free upgrade, TDBGridS1.OCX, I got complaints about the behavior of the grids when I entered or edited data in TDBGrid Standard. The cell pointer stays put and highlights the text just entered. The user must press the enter key a second time or use the arrow key to move to the next cell.

Three lines of code automatically move the cursor to the next cell after entering or editing a cell. The grid is in the Bound mode.

1. Create a form level variable:

        Dim KC as integer

2. In the TDBGridS1_Keydown Event:

Private Sub TDBGridS1_KeyDown(KeyCode _
        As Integer, Shift As Integer)
        KC = KeyCode    ' Trap the keycode
End Sub

3. In the TDBGridS1_AfterColEdit Event:

Private Sub _
        TDBGridS1_AfterColEdit(ByVal _
                ColIndex As Integer)
        ' statments go here
        ' on the last line use this code:
        If KC = 13 Then SendKeys "{Enter}"

End Sub

Philip Speck
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date