Private Sub MSHFlexGrid1_Click()
Call SizeText
Text1.Visible = True
Text1.SetFocus
End Sub
Private Sub MSHFlexGrid1_GotFocus()
MSHFlexGrid1_RowColChange
End Sub
Private Sub MSHFlexGrid1_LeaveCell()
MSHFlexGrid1.Text = Text1.Text
End Sub
Private Sub MSHFlexGrid1_RowColChange()
Static OldRow As Integer, OldCol As Integer, Change As Boolean
If Change Then Exit Sub
Change = True
With MSHFlexGrid1
If .Col <> OldCol Or .Row <> OldRow Then
OldRow = .Row
OldCol = .Col
Call SizeText
Text1.Visible = True
Text1.SetFocus
End If
End With
Change = False
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
With MSHFlexGrid1
Select Case KeyCode
Case vbKeyRight
If .Col + 2 > .Cols And .Row + 1 < .Rows Then
.Col = 1
.Row = .Row + 1
ElseIf .Col + 1 < .Cols And .Row < .Rows Then
.Col = .Col + 1
End If
Case vbKeyUp
If .Row - 1 > 0 Then .Row = .Row - 1
Case vbKeyDown, vbKeyReturn
If .Row + 1 < .Rows Then .Row = .Row + 1
Case vbKeyLeft
If .Col - 1 = 0 And .Row - 1 <> 0 Then
.Col = .Cols - 1
.Row = .Row - 1
ElseIf .Col - 1 <> 0 Then
.Col = .Col - 1
End If
End Select
End With
MSHFlexGrid1_RowColChange
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then KeyAscii = 0
If KeyAscii = vbKeyTab Then
Call Text1_KeyDown(vbKeyRight, 0)
KeyAscii = 0
End If
End Sub
Private Sub Text1_LostFocus()
Text1.Visible = False
Call MSHFlexGrid1_RowColChange
End Sub
Private Sub SizeText()
With MSHFlexGrid1
Text1.Text = .Text
Text1.FontSize = .Font.Size
Text1.Height = .CellHeight
If .CellLeft + .CellWidth > .Width Then
Text1.Width = .Width - .CellLeft
Else
Text1.Width = .CellWidth
End If
Text1.Left = .CellLeft + .Left
Text1.Top = .CellTop + .Top
End With
End Sub