Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSflexGrid Tooltip text 2

Status
Not open for further replies.

Chance1234

IS-IT--Management
Jul 25, 2001
7,871
US
how could i get a tooltip text to appear when a user is over a certain cell in a MSFlexgrid control ?

Filmmaker, gentlemen and East end club promoter



 
With MSFlexGrid1
.ToolTipText = .TextMatrix(.RowPosition(x), .ColPosition(y))
End With


peterguhl@yahoo.de
 
Assume grid has at least 3 rows and 3 columns.
The tooltip will appear when cursor is over cell(2,2) (the third cell from the left/top).

Private Sub MSFlexGrid1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim q, p, w, z

q = MSFlexGrid1.ColWidth(0) + MSFlexGrid1.ColWidth(1)
p = MSFlexGrid1.ColWidth(0) + MSFlexGrid1.ColWidth(1) + MSFlexGrid1.ColWidth(2)
w = MSFlexGrid1.RowHeight(0) + MSFlexGrid1.RowHeight(1)
z = MSFlexGrid1.RowHeight(0) + MSFlexGrid1.RowHeight(1) + MSFlexGrid1.RowHeight(2)

Me.Caption = x & " " & y

If (x >= q And x <= p) And (y >= w And y <= z) Then
MSFlexGrid1.ToolTipText = &quot;My tooltip!&quot;
Else
MSFlexGrid1.ToolTipText = &quot;&quot;
End If

End Sub
 
Here is the code that I use. good for any amount of cells.

Code:
Private Sub MSFlexGrid1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
   Dim C, R As Long
   Dim H1, H2, W1, W2 As Long
   Dim MyRowName, MyColName As String

   For R = 0 To MSFlexGrid1.Rows - 1
     H1 = MSFlexGrid1.RowPos(R)
     H2 = MSFlexGrid1.RowHeight(R)

     If y >= H1 And y <= (H1 + H2) Then
       MyRowName = &quot; Row = &quot; & R
       Exit For
     End If
   Next R

   For C = 0 To MSFlexGrid1.Cols - 1
     W1 = MSFlexGrid1.ColPos(C)
     W2 = MSFlexGrid1.ColWidth(C)

     If x >= W1 And x <= (W1 + W2) Then
       MyColName = &quot; Col = &quot; & C
       Exit For
     End If
   Next C

   MSFlexGrid1.ToolTipText = &quot;Position:&quot; & MyColName & MyRowName
End Sub


Thanks and Good Luck!

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top