MSFlexGrid Cell Editing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MiziaQ
    New Member
    • Nov 2007
    • 63

    MSFlexGrid Cell Editing

    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_Key Press(KeyAscii As Integer)

    Dim sTemp As String

    With MSFlexGrid1

    sTemp = .TextMatrix(.ro w, .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(.ro w, .Col) = sTemp
    End With

    End Sub
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Hi,

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

    [code=vb]
    Private Sub MSFlexGrid1_Key Press(KeyAscii As Integer)

    Dim sTemp As String

    With MSFlexGrid1

    sTemp = .TextMatrix(.ro w, .Col)

    Select Case KeyAscii
    Case 13 'Enter Key
    .TextMatrix(.Ro w, .Col ) =sTemp
    If .Col = .Cols-1 Then
    If .Row = .Rows - 1 Then
    sTemp = ""
    Exit Sub
    Else
    .Row = .Row +1
    .Col = 1 'Make this zero if First Col also is edittable
    sTemp = .TextMatrix(.ro w, .Col)
    End If
    Else
    .Col = .Col + 1
    sTemp = .TextMatrix(.ro w, .Col)
    End If
    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(.ro w, .Col) = sTemp
    End With

    End Sub
    [/code]

    Regards
    Veena

    Comment

    • realwish
      New Member
      • Mar 2008
      • 1

      #3
      How Can We Send Data From Msflexgrid To The Msaccess[img]

      Comment

      Working...