Search Tools Links Login

Make MSHFlexGrid Editable without help of any textbox or other control


Visual Basic 6, or VB Classic

Make MSHFlexGrid Editable without help of any textbox or other control

Original Author: Kazi Khalid

Assumptions

'Take an MSHFlexgrid name it as msh1

Code

'in the keypress event of msh1 write the following code.
Private Sub msh1_KeyPress(KeyAscii As Integer)
  Select Case KeyAscii
  
    Case vbKeyReturn, vbKeyTab
      'move to next cell.
      With msh1
        If .Col + 1 <= .Cols - 1 Then
          .Col = .Col + 1
        Else
          If .Row + 1 <= .Rows - 1 Then
            .Row = .Row + 1
            .Col = 0
          Else
            .Row = 1
            .Col = 0
          End If
        End If
      End With
      
    Case vbKeyBack
      With msh1
        'remove the last character, if any.
        If Len(.Text) Then
          .Text = Left(.Text, Len(.Text) - 1)
        End If
      End With
      
    Case Is < 32
    
    Case Else
      With msh1
        .Text = .Text & Chr(KeyAscii)
      End With
      
  End Select
End Sub

About this post

Posted: 2003-06-01
By: ArchiveBot
Viewed: 112 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.