INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Tips & Tricks

Display text, in Item Tips, in a multiple column List Box by Imaginecorp
Posted: 4 Feb 07

A list box with multiple columns will not display the full text of the Bound Column in Item Tips, if the width of the text is Less than the List Box width.

VFP uses an internal RTRIM() to display the text in an Item Tip. The idea here is to expand the text width to fool VFP into displaying it in Item Tips.

NOTE: this example works with the form Scale Mode set to Pixels, thus the +15 and -20, as FONTMETRIC() is not very accurate. (You may have to play with this.) Foxels will make it much easier, (Use REPLICATE() instead of PADR()).

Caution:
Do not specify a Control Source.
You could, by using STREXTRACT().
If the value is being used to update a field use STREXRACT().

Hover over the text in the list box, column 1, and if the text width is larger than the 1st column width it will display the text in the Item Tips.

CODE

******* VFP9 with SP 1
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN


    **************************************************
*-- Form:         form1 (\imaginecorp\form1.scx)
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   02/01/07 09:50:14 PM
*
DEFINE CLASS form1 AS form


    Top = 3
    Left = 48
    DoCreate = .T.
    Caption = "Show Item Tips..."
    Name = "Form1"


    ADD OBJECT list1 AS listbox WITH ;
        ColumnCount = 2, ;
        ColumnWidths = "140,70", ;
        Height = 179, ;
        Left = 45, ;
        Top = 27, ;
        Width = 236, ;
        ItemTips = .T., ;
        Name = "List1"


    ADD OBJECT command1 AS commandbutton WITH ;
        Top = 218, ;
        Left = 281, ;
        Height = 27, ;
        Width = 84, ;
        Caption = "Close", ;
        Name = "Command1"


    ADD OBJECT label1 AS label WITH ;
        AutoSize = .T., ;
        Caption = "Company", ;
        Height = 17, ;
        Left = 51, ;
        Top = 10, ;
        Width = 55, ;
        Name = "Label1"


    ADD OBJECT label2 AS label WITH ;
        Caption = "ID", ;
        Height = 17, ;
        Left = 196, ;
        Top = 10, ;
        Width = 40, ;
        Name = "Label2"


    PROCEDURE Load
        If Used("customer")
            Use In customer
        Endif
        Select 0
        Use Home()+"samples\data\customer.dbf"
    ENDPROC


    PROCEDURE list1.Init
        Local nFontSize,nFieldWidth,nFirstColumn

        Select customer

        nFontSize = Fontmetric(6,Thisform.list1.FontName,Thisform.list1.FontSize)
        nFieldWidth = Thisform.list1.Width-(Fsize("company","customer")* nFontSize)
        nFirstColumn = Val(Strextract(Thisform.list1.ColumnWidths,"",",",1))

        Select ICASE((Len(Alltrim(customer.company))* nFontSize) >= (nFirstColumn-20),;
            Padr(customer.company,(nFieldWidth+15),".") ,customer.company) as company ,;
            customer.cust_id ;
            FROM customer ;
            INTO Cursor custcursor
        With This
            .ItemTips = .T.
            .RowSource = "custcursor.company,cust_id"
            .rowsourcetype = 6
            .Value = .TopIndex
        Endwith
    ENDPROC


    PROCEDURE command1.Click
        USE IN customer
        thisform.release
    ENDPROC


ENDDEFINE
*

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close