By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,619 Members | 2,698 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,619 IT Pros & Developers. It's quick & easy.

MSFlexGrid Cell Editing

P: 63
Hey, how can I allow the user to edit ANY cell from any row and column in an msflexgrid ? I found the following code, but it only allows input for the first column. Thank you in advance.

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
Mar 9 '08 #1
Share this Question
Share on Google+
2 Replies


QVeen72
Expert 100+
P: 1,445
Hi,

For "Enter" key press, you need to move on to new cell..
Roughly like this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)
  2.  
  3. Dim sTemp As String
  4.  
  5. With MSFlexGrid1
  6.  
  7. sTemp = .TextMatrix(.row, .Col)
  8.  
  9. Select Case KeyAscii
  10. Case 13  'Enter Key
  11.  .TextMatrix(.Row, .Col  ) =sTemp
  12.   If .Col = .Cols-1 Then
  13.       If .Row = .Rows - 1 Then
  14.          sTemp = ""
  15.          Exit Sub
  16.       Else
  17.           .Row = .Row +1
  18.           .Col = 1 'Make this zero if First Col also is edittable
  19.          sTemp = .TextMatrix(.row, .Col)
  20.       End If
  21.   Else
  22.       .Col = .Col + 1
  23.          sTemp = .TextMatrix(.row, .Col)
  24.   End If
  25. Case 8 ' backspace
  26. If Len(sTemp) > 0 Then
  27. sTemp = Left$(sTemp, Len(sTemp) - 1)
  28. End If
  29. Case 27 ' escape
  30. sTemp = ""
  31. Case 0 To 31
  32. KeyAscii = 0
  33. Case Else
  34. sTemp = sTemp & Chr$(KeyAscii)
  35. End Select
  36. .TextMatrix(.row, .Col) = sTemp
  37. End With
  38.  
  39. End Sub
  40.  
Regards
Veena
Mar 10 '08 #2

P: 1
How Can We Send Data From Msflexgrid To The Msaccess[img]
Mar 17 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.