2
Private Sub Grid1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

    If  ????????????  Then Grid1.ToolTipText = <contents of cell>

End Sub

如何使用XY坐标来确定鼠标指针当前位于哪个单元格上?

Grid我正在使用的实现只有一个MouseMove事件而不是一个MouseOver事件。

4

1 回答 1

1
Private Sub Grid1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
  Dim intRow As Integer, intCol As Integer
  With Grid1
    For intRow = 0 To .Rows - 1
      If y > .RowPos(intRow) Then
        If y < .RowPos(intRow) + .RowHeight(intRow) Then
          For intCol = 0 To .Cols - 1
            If x > .ColPos(intCol) Then
              If x < .ColPos(intCol) + .ColWidth(intCol) Then
                .ToolTipText = .TextMatrix(intRow, intCol)
              End If
            End If
          Next intCol
        End If
      End If
    Next intRow
  End With 'Grid1
End Sub
于 2012-11-19T09:42:45.123 回答