by Jared Odulio (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 3.0
Difficulty: Advanced
Date Added: Wed 3rd February 2021
Rating:
(18 Votes)
This code allows users to edit in a MSFlexGrid
Assumes
Just copy and paste this code in the KeyPress event of your MSFlexGrid
Side Effects
No side effects
Private Sub MyFlexGrid_KeyPress(KeyAscii As Integer)
'Provides manual data entry capability to flexgrid
With MyFlexGrid
Select Case KeyAscii
Case vbKeyReturn
If .Col + 1 <= .Cols - 1 Then
.Col = .Cols - 1
ElseIf .Row + 1 <= .Rows - 1 Then
.Row = .Row + 1
.Col = 0
Else
.Row = 1
.Col = 0
End If
Case vbKeyBack
If Trim(.Text) <> "" Then
.Text = Mid(.Text, 1, Len(.Text) - 1)
End If
Case Is < 32
Case Else
If .Col = 0 Or .Row = 0 Then
Exit Sub
Else
.Text = .Text & Chr(KeyAscii)
End If
End Select
End With
End Sub