Change borderstyle on mouse hover

S

Saber

glb is a global string, I want when moving mouse to a picturebox, change
border style of picturebox.
the code shown below do that but MouseLeave event fires less than a second
after MouseHover,
even without leaving the mouse pointer or moving that.
I also tried MouseEnter event instead of MouseHover, but they act same here.


Private Sub p1_MouseHover(ByVal sender As Object, ByVal e As
System.EventArgs) Handles p1.MouseLeave, p2.MouseEnter, p3.MouseEnter,
p4.MouseEnter, p5.MouseEnter, p6.MouseEnter, p7.MouseEnter, p8.MouseEnter,
p9.MouseEnter, p10.MouseEnter, p11.MouseEnter, p12.MouseEnter

sender.BorderStyle = BorderStyle.FixedSingle
glb = sender.Name

End Sub


Private Sub p1_MouseLeave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles p1.MouseLeave, p2.MouseEnter, p3.MouseEnter,
p4.MouseEnter, p5.MouseEnter, p6.MouseEnter, p7.MouseEnter, p8.MouseEnter,
p9.MouseEnter, p10.MouseEnter, p11.MouseEnter, p12.MouseEnter

If glb = sender.Name Then sender.BorderStyle = BorderStyle.None

End Sub
 
C

Claes Bergefall

In your code below, p1_MouseHover and p1_MouseLeave both handles the
exact same events. Unless this is a typo in your post I'd say this is the
problem

/claes
 
S

Saber

Thanks, I've been sleepy and didn't notice that!

Claes Bergefall said:
In your code below, p1_MouseHover and p1_MouseLeave both handles the
exact same events. Unless this is a typo in your post I'd say this is the
problem

/claes
 

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

Top