Results 1 to 3 of 3

Thread: ListBox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Posts
    225
    Hiyas,

    How can I make it so when I have the mouse over a listbox's item, the tooltip text displays that item's text?

    Thanks.

    -Git

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    '
    'had to make a fix on this works now
    '
    Option Explicit
    
    'using a tooltip for the list items in a listbox
    'with a mouse move event.
    
    'Here's the mouse move event for your listbox "List1" :
    
    
    Private Sub Form_Load()
    Dim x As Integer
    For x = 1 To 10
    List1.AddItem "Hello " & x & " Times"
    Next x
    
    End Sub
    
    Private Sub List1_MouseMove _
    (Button As Integer, Shift As Integer, _
    x As Single, Y As Single)
    
    Dim cv, tps, bs, ts, r, wr, rn, num
    'whats the twips/point conversion?
    cv = 20 '20 twips = 1 point
    'how many twips are added to the
    'font size to make up a row?
    tps = 30
    'whats the border size of the list in twips?
    bs = 40
    
    'see if mouse pointer is on the list box
    If x > 10 And x < List1.Width - 80 Then
        If Y > 10 And Y < List1.Height - 80 Then
            'whats the twip size of every row?
                ts = List1.FontSize * cv + tps
            'how many rows does the list display?
                r = (List1.Height - bs) / ts
            'what's the exact width of every row?
                wr = List1.Height / r
            'what row number from the top is the mouse over?
                rn = Int(Y / wr)
            'what list item number is that?
                num = List1.TopIndex + rn
            'display tool tip text
                List1.ToolTipText = List1.List(num)
        End If
    End If
    End Sub

    [Edited by HeSaidJoe on 09-09-2000 at 11:28 PM]
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Posts
    225
    Hi,

    Cool, works perfectly. =))

    Is there anyway to change the colour of the tool tip text/background?

    Thanks,

    -Git

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width