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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I add ToolTipText to grid columns and headers?

Grids

How can I add ToolTipText to grid columns and headers?

by  ChrisRChamberlain  Posted    (Edited  )
Grid columns and headers do not have a [color blue].ToolTipText[/color] property, so, for instance, if you have a grid with checkboxes without text, it's difficult for a user to know what clicking on the checkbox does.

Equally using text with a checkbox can be a large waste of space.

ToolTipText will only show for a control in a column when the control gets focus, so passing the mouse up and down a column without any help in the form of ToolTipText can also be confusing to a user.

You can add ToolTipText to grid columns and headers in VFP 7.0 and later by using the following code.

Create a new form method called [color blue].mToolTipText()[/color].

In the [color blue].mToolTipText()[/color] method of the form put :-
[color blue]
LPARAMETERS tnLeft, tnTop, tcText

IF !EMPTY(tcText)
[tab]WITH THIS
[tab][tab][tab]IF VARTYPE(.lblToolTipText) =
[tab][tab][tab][tab].AddObject([lblToolTipText],[label])

[tab][tab][tab][tab]WITH .lblToolTipText
[tab][tab][tab][tab][tab].AutoSize = .T.
[tab][tab][tab][tab][tab].BackColor = RGB(255,255,215)
[tab][tab][tab][tab][tab].BorderStyle = 1
[tab][tab][tab][tab][tab].FontName = [MS Sans Serif]
[tab][tab][tab][tab]ENDWITH
[tab][tab][tab]ENDIF

[tab][tab][tab]WITH .lblToolTipText
[tab][tab][tab][tab].Caption = tcText
[tab][tab][tab][tab].Left = tnLeft
[tab][tab][tab][tab].Top = tnTop + 15
[tab][tab][tab][tab].Visible = .T.
[tab][tab]ENDWITH
[tab]ENDWITH
ENDIF[/color]

In the [color blue].MouseEnter()[/color] events of the columns and headers put :-
[color blue]
lcToolTipText = [Whatever you need here]
THISFORM.mToolTipText(nXCoord,nYCoord,lcToolTipText)[/color]

If you prefer to use the .ToolTipText property available in VFP 8.0/9.0 instead of the variable lcToolTipText, in the [color blue].MouseEnter()[/color] events of the columns and headers put:-
[color blue]
THISFORM.mToolTipText(nXCoord,nYCoord,THIS.ToolTipText)[/color]

In the [color blue].MouseLeave()[/color] events of the columns and headers put :-
[color blue]
WITH THISFORM
[tab]IF VARTYPE(.lblToolTipText) = [O]
[tab][tab].lblToolTipText.Visible = .F.
[tab]ENDIF
ENDW[/color]

Have fun.

FAQ184-2483 - answering getting answered.​
Chris [pc2]
[link http://www.motrac.co.uk]motrac.co.uk[/link]
[link http://www.pdfcommander.com]PDFcommander[sup]tm[/sup].com[/link]
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top