Click here to Skip to main content
12,065,756 members (29,736 online)
Rate this:
 
Please Sign up or sign in to vote.
I have created a user control but it's mouse enter and mouse leave events are not get fired.
Please Help Me.


Public Class ButtonTemplet
    Inherits UserControl
 
    Private mButtonText As String
    Public Property ButtonText As String
        Set(value As String)
            lblTitle.Text = value
        End Set
        Get
            Return lblTitle.Text
        End Get
    End Property
 
    Private Sub ButtonTemplet_MouseEnter(sender As System.Object, e As System.EventArgs) Handles MyBase.MouseEnter
        Me.BackgroundImage = Global.WindowsApplicationDemo.My.Resources.Resources.Clients_grey_button_Templet
        Me.lblTitle.ForeColor = Color.White
    End Sub
 
    Private Sub ButtonTemplet_MouseLeave(sender As System.Object, e As System.EventArgs) Handles MyBase.MouseLeave
        Me.BackgroundImage = Global.WindowsApplicationDemo.My.Resources.Resources.Orders_white_button_Templet
        Me.lblTitle.ForeColor = Color.Gray
    End Sub
 
    Protected Overrides Sub OnMouseEnter(e As System.EventArgs)
        MyBase.OnMouseEnter(e)
        Me.BackgroundImage = Global.WindowsApplicationDemo.My.Resources.Resources.Clients_grey_button_Templet
        Me.lblTitle.ForeColor = Color.White
    End Sub
 
    Protected Overrides Sub OnMouseLeave(e As System.EventArgs)
        MyBase.OnMouseLeave(e)
        Me.BackgroundImage = Global.WindowsApplicationDemo.My.Resources.Resources.Orders_white_button_Templet
        Me.lblTitle.ForeColor = Color.Gray
    End Sub
End Class
Posted 7-May-13 5:23am
PSAFOL518
Comments
Sandeep Mewara 7-May-13 10:38am
   
Are the defined events tied up?
   
You don't show the definitions of any events in your code sample. I can imaging that you have it in your auto-generated (by the designer) part of the class. But then, where is "Partial"? The problem is: instead of showing the code which could compile, you show who knows what. When you ask a question, you should better show some code sample, not your own code, but this code should be complete.
The part of the code which you show does not look reasonable.
—SA

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

If I remember correctly, those events will only fire if the mouse is over a portion of the UserControl surface that does NOT have a constituent control on it. So, for example, if you have a button that is Dock.Filled to the entire UserControl surface, those event will never fire because the mouse cannot see the UserControl surface, only the button sitting on top of it.
  Permalink  
Comments
PSAFOL 8-May-13 1:43am
   
Thank You very much Dave Kreskowiak. I was solving it from 2 days, but you have solved it in 5 mins. Thank You very much.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web03 | 2.8.160207.1 | Last Updated 7 May 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100