ToolTip Demo

The example below shows how you can use the MouseRow and MouseCol properties to implement ToolTips with text that changes as the mouse moves over the control.

    Sub fg_MouseMove(Button As Integer, Shift As Integer, _

                     X As Single, Y As Single)

        Static r As Long, c As Long

        Dim nr As Long, nc As Long

   

        ' get coordinates

        nr = fg.MouseRow

        nc = fg.MouseCol

   

        ' update ToolTip text

        If c <> nc Or r <> nr Then

            r = nr

            c = nc

            fg.ToolTipText = "Row:" & r & " Col:" & c

        End If

   

        ' other processing...

 

    End Sub

The code keeps track of the last cell for which ToolTips were displayed, and refreshes the ToolTipText only when needed. This is done to avoid flicker.