This time we will practice how to control MSHFlexgrid just like excel can be edited, without the help of other components. Whether it can be done by MSHFlexgrid ? The answer is that it can.
          Open a new project in VB6 you, then add the control MSHFlexgrid. On the property form KeyPreview = true property setting. Then in the keypress event of MSHFlexgrid add the following:
 
 
 Private Sub MSHFlexgrid1_KeyPress(KeyAscii As Integer)
 Select Case KeyAscii
           Case vbKeyReturn, vbKeyTab
                   If MSHFlexgrid1.Col + 1 <= MSHFlexgrid1.Cols - 1 Then
                      MSHFlexgrid1.Col = MSHFlexgrid1.Col + 1
                      Else
                      If MSHFlexgrid1.Row + 1 <= MSHFlexgrid1.Rows - 1 Then
                          MSHFlexgrid1.Row = MSHFlexgrid1.Row + 1
                          MSHFlexgrid1.Col = 0
                          Else
                          MSHFlexgrid1.Row = 1
                          MSHFlexgrid1.Col = 0
                      End If
                  End If
            Case vbKeyBack
                   If Len(MSHFlexgrid1.Text) Then
                       .Text = Left(MSHFlexgrid1.Text, Len(MSHFlexgrid1.Text) - 1)
                       End If
           Case Is < 32
           Case Else
                  MSHFlexgrid1.Text = MSHFlexgrid1.Text & Chr(KeyAscii)
 End Select
 End Sub
 

 
          Then run the program via the menu in vb6 you, place the cursor on the control MSHFlexgrid, then do the edit process. If your program is correct then the editing process on the cell in the control MSHFlexgrid will run normally.


More topic of Mshflexgrid
 
 -. How to Use MSHFlexgrid ?
 -. Mshflexgrid with Adodc

 -. Attach textbox to MSHFlexgrid
 -. Select Single Cell in MSHFlexgrid
 -. MSHFlexgrid select a cell and change background
Categories: