Solved

Mouse Hover, Focus and Mouse Leave

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
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 …
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…

749 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