Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Edit Cursor in Data Grid 1

Status
Not open for further replies.

TripleJHJO

Programmer
Jan 10, 2003
76
0
0
US
I am using VB6. I have a datagrid object that is bound to a recordset. When I load the recordset, I want the cursor to move to the first column and last row (new record) of the grid. I am using the following code to do this:

dbGrid.Row = rs.RecordCount + 1

When I first enter data into the grid, I have to press a key twice. Once makes the cursor appear and the second keypress displays the character.

How do I eliminate the double keypress and have the cursor in the ready position right out of the chute?

Thanks,

J.Jensen
 
Stick this into the Grid's RowColChange event
Code:
Private Sub dbGrid_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
    If (Not IsNull(LastRow)) Then
        With dbGrid
            If (.Row >= 0) And (.col >= 0) Then
                .EditActive = True
                .SelLength = Len(.Text)
                .SelStart = Len(.Text)
            End If
        End With
    End If
End Sub
 
Worked great.
Thought about doing something along those lines, but thought I was way over-engineering something that could be done more simple.

Thanks very much.

J.Jensen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top