phadaphunk phadaphunk - 1 month ago 5
Vb.net Question

Tooltip showing twice

I'm showing a

ToolTip
on a certain button's
MouseHover
event. If I go over it once it works but if I leave, wait for the tooltip to disapear and come back on the button, it appears twice. I tried cancelling it on
MouseLeave
but it still appear twice the seocnd time.

Private Sub someButton_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles someButton.MouseHover

Dim tooltipSearch As New ToolTip()
tooltipSearch.Show("I'm a tooltip"), someButton)

End Sub

Private Sub someButton_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles someButton.MouseLeave

Dim toolTip As New ToolTip()
toolTip.GetToolTip(someButton)
toolTip.Hide(someButton)
toolTip.Dispose()

End Sub


Am I missing something obvious?

Answer

You are using the ToolTip not in the way it should be used (also look at the documentation :) ). It is just like any other control, start by dragging it onto your form (like you do with other controls).

If you have no dynamic text to be displayed in your tooltip, you can easily set the text in your constructor, using the method SetToolTip. If you do want some dynamic text, you can use this method in your MouseHover event.

Apart from that, you shouldn't do anything anything else. Just set the right delays on your tooltip and it should work all fine.