Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Mouse Hover, Focus and Mouse Leave

Posted on 2014-04-16
3
Medium Priority
?
993 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 2000 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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
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…
Starting up a Project

670 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