Mouse Hover

  • Thread starter Thread starter Tom McL.
  • Start date Start date
T

Tom McL.

I have a listbox that is quite small in width but the data loaded into
the listbox can be longer then can be seen. I would like to
rest the mouse on a line and be able to see the entire contents.

Microsoft uses this practice quite extensively, how can this be done?I

Tom
 
Tom McL. said:
I have a listbox that is quite small in width but the data loaded into
the listbox can be longer then can be seen. I would like to
rest the mouse on a line and be able to see the entire contents.

Add a ToolTip component to your form, then add this code:

\\\
Private Sub ListBox1_MouseMove( _
ByVal sender As Object, _
ByVal e As MouseEventArgs _
) Handles ListBox1.MouseMove
Dim SourceControl As ListBox = DirectCast(sender, ListBox)
Dim n As Integer = SourceControl.IndexFromPoint(e.X, e.Y)
Dim s As String
If n <> ListBox.NoMatches Then
s = SourceControl.Items(n)
Else
s = ""
End If
If Me.ToolTip1.GetToolTip(SourceControl) <> s Then
Me.ToolTip1.SetToolTip(SourceControl, s)
End If
End Sub
///
 
Private Sub ListBox1_SelectedValue(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ListBox1.SelectedValueChanged

Dim Tooltip As New ToolTip

Tooltip.SetToolTip(ListBox1, ListBox1.SelectedItem)

End Sub

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top