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
如何使用X
和Y
坐标来确定鼠标指针当前位于哪个单元格?
我使用的Grid
的实施只有MouseMove
个事件,而不是MouseOver
个事件。
答案 0 :(得分: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