Solved

Mouse Hover, Focus and Mouse Leave

Posted on 2014-04-16
3
946 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

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.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Six Sigma Control Plans
Starting up a Project

627 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