Solved

Tool tips equivalent

Posted on 1999-01-29
5
210 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

758 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

19 Experts available now in Live!

Get 1:1 Help Now