Click here to Skip to main content
Rate this: bad
good
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
 
<pre>
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
PSAFOL458
Comments
Sandeep Mewara at 7-May-13 10:38am
   
Are the defined events tied up?
Sergey Alexandrovich Kryukov at 7-May-13 10:51am
   
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 at 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
0 OriginalGriff 490
1 Sergey Alexandrovich Kryukov 335
2 ProgramFOX 265
3 Maciej Los 245
4 Andreas Gieriet 200
0 OriginalGriff 465
1 Sergey Alexandrovich Kryukov 275
2 ProgramFOX 265
3 Maciej Los 245
4 Andreas Gieriet 200


Advertise | Privacy | Mobile
Web01 | 2.8.150331.1 | Last Updated 7 May 2013
Copyright © CodeProject, 1999-2015
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