Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

Tool tips equivalent

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
timjc
Asked:
timjc
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
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
 
timjcAuthor Commented:
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
 
Éric MoreauSenior .Net ConsultantCommented:
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
 
jbilCommented:
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
 
anzenCommented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now