Hover in VB.Net

Mattg1981

Newcomer
Joined
Oct 27, 2002
Messages
10
I am reading this book VB.Net Step by Step and getting a head jump on vb before I take it in college. At any rate .. the author wrote something in here and I checked his errors page online and this is not listed, so I was wondering if it was me or if it is an error

I used this code for the hover (after selecting the listbox in Classname and MouseHover in Method Name)

If listbox.selectedindex < 0 Or listbox.selectedindex > 4 Then
label.Text = "blah blah blah"
End If

Now he said that you should have to hold the mouse on top of a listbox selection for a few moments and then the hover message would pop up. But the moment I hover over a selection that message pops up. I have tried playing around with this code a while and cant find a combination of <'s or >'s, and, or, AndAlso, OrElse and a ton others that will make this delay work. Can someone explain what I have to do to correct this problem.

Also, I was wondering another thing. When I do hover and get the message, that message stays, until I select the selectedindex and then the message goes away. What would I have to add to the code to make it so that when I hover over it (with the correct specified hover time) it would show the message, but when I moved my mouse to another section of the form, the message would go away, and of course then come back again when I hover over a selection again.
 
There is a mouseleave event where you could clear the box if you wished.

If he said that that code would make the text appear when you move the mouse over the listbox, he is correct. It won't do anything apart from that though.
 
Well, yes, I am getting the text to appear, but there is supposed to be a delay (I am guessing 4 seconds) but mine is appearing automatically.
 
You could use a Timer component, starting it when the mouse enters the area and stopping it if the mouse leaves the area before it has activated.
 
Any chance that you meant to be using a text tool tip, rather than assigning text to a label?

Because if you use a tool tip then when you hover over it, there is a delay before the text appears, and it goes away after you exit the list area.
 
Back
Top