.TextMatrix(j, 0) = "行" & j
Next j
End With
End Sub
'对表格内容读功能的实现
'当前活动单元更改到一个不同单元时发生,实现 Text2文本的漂浮跟踪
Private Sub Grid1_EnterCell()
If Grid1.Row = 0 Or Grid1.Col = 0 Then Exit Sub
With Text2
.Text = ""
.Visible = False
.Top = Grid1.Top + Grid1.CellTop
.Left = Grid1.Left + Grid1.CellLeft
.Width = Grid1.CellWidth
.Height = Grid1.CellHeight
.Text = Grid1.Text
.Visible = True
.SetFocus
End With
End Sub
'对表格内容写功能的实现
'当前活动单元变更到一个不同的单元之前立即发生,实现Text2文本中的值添加到单元格中
Private Sub Grid1_LeaveCell()
Grid1.Text = Text2.Text
Text2.Text = ""
Text2.Visible = False
End Sub
'提高操作性的功能代码
'通过方向键来控制光标所在单元格中的位置
Private Sub Text2_Keydown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case 39 '向右
Grid1.SetFocus
If Grid1.Col < Grid1.Cols Then Text2.Left = Grid1.Left + Grid1.CellLeft
Case 37 '向左
Grid1.SetFocus
If Grid1.Col > 1 Then Text2.Left = Grid1.Left - Grid1.CellLeft
Case 40 '向下
Grid1.SetFocus
If Grid1.Row < Grid1.Rows Then Text2.Top = Grid1.Top + Grid1.CellTop
Case 38 '向上
Grid1.SetFocus
If Grid1.Row <= 2 Then
|