Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 408
  • Last Modified:

allow only one column to edit in msflexgrid

Using the following code in vb6, I have opened all columns for edit

Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)

Dim sTemp As String

With MSFlexGrid1

sTemp = .TextMatrix(.Row, .Col)

Select Case KeyAscii
Case 8 ' backspace
If Len(sTemp) > 0 Then
sTemp = Left$(sTemp, Len(sTemp) - 1)
End If
Case 27 ' escape
sTemp = ""
Case 0 To 31
KeyAscii = 0
Case Else
sTemp = sTemp & Chr$(KeyAscii)
End Select
.TextMatrix(.Row, .Col) = sTemp
End With

End Sub

Open in new window


How do I limit the editing to only to the 7th column in my table

I am using vb6 and msflexgrid
0
al4629740
Asked:
al4629740
  • 2
1 Solution
 
Martin LissRetired ProgrammerCommented:
Try

Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)

Dim sTemp As String

With MSFlexGrid1

sTemp = .TextMatrix(.Row, .Col)

If .Col <> 6 Then Exit Sub ' This might need to be 7
Select Case KeyAscii
Case 8 ' backspace
If Len(sTemp) > 0 Then
sTemp = Left$(sTemp, Len(sTemp) - 1)
End If
Case 27 ' escape
sTemp = ""
Case 0 To 31
KeyAscii = 0
Case Else
sTemp = sTemp & Chr$(KeyAscii)
End Select
.TextMatrix(.Row, .Col) = sTemp
End With

Open in new window

0
 
al4629740Author Commented:
6 is right
0
 
Martin LissRetired ProgrammerCommented:
I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now