devxlogo

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

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 enteredor edited data in TDBGrid Standard. The cell pointer stays putand highlights the text just entered. The user must press theenter key a second time or use the arrow key to move to the nextcell.

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

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 keycodeEnd 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
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist