Search a record on a FlexGrid on KeyPress Event


Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)
Dim i, j As Integer
Static test As String
If KeyAscii >= 33 And KeyAscii <= 126 Then
test = test & Chr(KeyAscii)
With MSFlexGrid1
For i = 1 To .Rows – 1
j = InStr(.TextMatrix(i, 0), test)  ‘Move Active Cell on Your desired Position
If (j = 1) Then
.Row = i
.Col = 0
.RowSel = i
.ColSel = .Cols – 1
.TopRow = i
Exit Sub
End If
Next
test = “”
test = test & Chr(KeyAscii)
For i = 1 To .Rows – 1
j = InStr(.TextMatrix(i, 0), test)
If (j = 1) Then
.Row = i
.Col = 0
.RowSel = i
.ColSel = .Cols – 1
.TopRow = i
Exit Sub
End If
Next
End With
End If

End Sub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s