Solved

Mouse Hover, Focus and Mouse Leave

Posted on 2014-04-16
3
791 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 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

22 Experts available now in Live!

Get 1:1 Help Now