Solved

Tool tips equivalent

Posted on 1999-01-29
5
211 Views
Last Modified: 2010-05-03
I want to be able to click on an item in a multi-column listbox and show the equivalent of a tooltip label if the text isn't fully displayed because the list box is not wide enough. How do you do this ? If you can't, please can you suggest an alternative.

Thanx.
0
Comment
Question by:timjc
5 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 1471160
Put an invisible label on your form.

Then, in the MouseUp event you move your label to the X and Y coordinates the the event gives you and make your label visible.
0
 

Author Comment

by:timjc
ID: 1471161
How do I stop that label from being partially hidden by the form should it want to reach further to the right than the form is ?
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 1471162
When you want to show the label, check that X + label.Width is less than form.scalewidth.

If not, you can move your label some twips to the left.

Maybe you can deal with autosize and wordwrap property of the label.
0
 
LVL 3

Expert Comment

by:jbil
ID: 1471163
Also you could use tooltips and change it's text

like this.........

Private Sub List1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim ypos

ypos = Int(Y / (List1.FontSize * 25))
List1.ToolTipText = List1.List(ypos)

End Sub
0
 
LVL 4

Accepted Solution

by:
anzen earned 30 total points
ID: 1471164
Try this:

Create a new project, add a listbox to Form1 and call it
lstTest, next insert the following code in Form1:

Private Sub Form_Load()
    Dim iItem As Integer
   
    With lstTest
        For iItem = 0 To 1000
            .AddItem "Item #" & iItem
            .ItemData(.NewIndex) = Int((1000 - 101) * Rnd + 100)
        Next iItem
    End With
End Sub

Private Sub lstTest_Click()
    With lstTest
        If .ListIndex <> -1 Then
            .ToolTipText = .List(.ListIndex) & " (Value=" & .ItemData(.ListIndex) & ")"
        End If
    End With
End Sub

now, whenever You click an item on the list the tooltip will
be changed to reflect the data of the selected item

Byte

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need VBS version of Excel date conversion 4 64
VBA color chart bars 12 76
How to compare ms sql hashbytes results within vb6 5 51
Excel Automation VBA 19 25
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now