Solved

Mouse Hover, Focus and Mouse Leave

Posted on 2014-04-16
3
841 Views
Last Modified: 2014-04-30
Hello,

I am having a problem with mouse hovering and mouse leaving on a panel using VB.NET. I have a panel which changes colour as you hover the mouse over it and then as the mouse leaves the colour changes back to the original colour.  The issue I have is that if I use the mouse hover as the mouse hovers over labels and text boxes the colour doesn’t hold. I’ve used the Focus but then it stays to the colour set but the mouse leave doesn’t work.
Can anyone advise on another method?
0
Comment
Question by:lincstech
3 Comments
 
LVL 22

Expert Comment

by:plusone3055
ID: 40004004
ive done it this way

Private Sub YouPanelNameMouseHover(ByVal sender As Object, ByVal e As  System.EventArgs)
    Dim YourPanelName As Panel = CType(sender, Panel)
    panel.BackColor = Color.Purple
    End Sub


Private Sub YouPanelNameMouseLeave(ByVal sender As Object, ByVal e As  System.EventArgs)
    Dim YourPanelName As Panel = CType(sender, Panel)
    panel.BackColor = Color.Grey
    End Sub
0
 

Author Comment

by:lincstech
ID: 40004097
That's good however if you add a few text boxes and labels into the panel and you hover over them the mouse leaves and the colour changes.
0
 
LVL 9

Accepted Solution

by:
dustock earned 500 total points
ID: 40004330
You can add the controls in the panel to the handles of the event.  I just added a panel and a few controls to an existing form then added those controls after the Handles.

    Private Sub Panel1_MouseEnter(sender As System.Object, e As System.EventArgs) Handles Panel1.MouseEnter, Label1.MouseEnter, TextBox4.MouseEnter, Button2.MouseEnter
        Panel1.BackColor = Color.LightCoral
    End Sub

    Private Sub Panel1_MouseLeave(sender As System.Object, e As System.EventArgs) Handles Panel1.MouseLeave, Label1.MouseEnter, TextBox4.MouseEnter, Button2.MouseEnter
        Panel1.BackColor = SystemColors.Control
    End Sub

Open in new window

0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Crystal reports vb.net 2 39
JQuery JavaScripot loop though RadioButtonList 4 23
write xml in vb.net 2 24
DataTables + iCheck + pagination Issue 2 14
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now