d1.SelStartRow = 1 ''网格中单元格的列、行初始位置
Grid1.LeftCol = 1
Grid1.TopRow = 1 ''网格中左上角的列、行初始位置
End Sub
Private Sub Grid1_MouseDown(Button As Integer,
Shift As Integer, X As Single, Y As Single)
Grid1.Col = Grid1.SelStartCol
Grid1.Row = Grid1.SelStartRow
Text1.Text = Grid1.Text
colnum = Grid1.Col - Grid1.LeftCol + 1
rownum = Grid1.Row - Grid1.TopRow + 1
Text1.Left = Grid1.Left + (Grid1.ColWidth(0)
+ Grid1.GridLineWidth * 12) * colnum
Text1.Top = Grid1.Top + (Grid1.RowHeight(0)
+ Grid1.GridLineWidth * 12) * rownum
End Sub
Private Sub Grid1_MouseUp(Button As Integer,
Shift As Integer, X As Single, Y As Single)
Text1.SetFocus
End Sub
Private Sub HScroll1_Change()
startcol = Grid1.LeftCol
Grid1.LeftCol = HScroll1.Value
Grid1.SelStartCol = Grid1.SelStartCol
+ Grid1.LeftCol - startcol
Grid1.Col = Grid1.SelStartCol
Text1.Text = Grid1.Text
End Sub
Private Sub Text1_Change()
Grid1.Text = Text1.Text
End Sub
Private Sub Text1_KeyDown(KeyCode
As Integer, Shift As Integer)
Select Case KeyCode
Case 38 '' 光 标 向 上
Grid1.Text = Text1.Text
If Grid1.SelStartRow <2 Then If Grid1.TopRow> 1 Then
VScroll1.Value = VScroll1.Value - 1
Else
Grid1.SelStartRow = 1
End If
Else
If Grid1.TopRow = Grid1.SelStartRow Then
VScroll1.Value = VScroll1.Value - 1
Else
Grid1.SelStartRow = Grid1.SelStartRow - 1
End If
End If
Grid1.Col = Grid1.SelStartCol
Grid1.Row = Grid1.SelStartRow
colnum = Grid1.Col - Grid1.LeftCol + 1
rownum = Grid1.Row - Grid1.TopRow + 1
Text1.Text = Grid1.Text
Text1.Left = Grid1.Left + (Grid1.ColWidth(0)
+ Grid1.GridLineWidth * 12) * colnum
Text1.Top = Grid1.Top + (Grid1.RowHeight(0)
+ Grid1.GridLineWidth * 12) * rownum
Exit Sub
Case 40 '' 光 标 向 下
Grid1.Text = Text1.Text
If Grid1.SelStartRow > inputrownum - 1 Then
If Grid1.TopRow <Grid1.Rows inputrownum Then VScroll1.Value="VScroll1.Value" + 1 Else If VScroll1.Value="VScroll1.Max" And Grid1.SelStartRow < Grid1.Rows 1 Then Grid1.SelStartRow="Grid1.SelStartRow" + 1 Else Grid1.SelStartRow="Grid1.Rows" 1 End If End If Else If Grid1.TopRow="Grid1.SelStartRow" inputrownum Then VScroll1.Value="VScroll1.Value" + 1 Else Grid1.SelStartRow="Grid1.SelStartRow" + 1 End If End If Grid1.Col="Grid1.SelStartCol" Grid1.Row="Gri