Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Usercontrol Event Propagation

Status
Not open for further replies.

Thrakazog

Programmer
Dec 10, 2001
48
US
I'm building a user control that contains label controls. I have a mouseup event for this user control on my form. My problem is that I can't get the mouseup events from the labels to raise the mouseup event for the user control on the form.

In the usercontrol I have this code:

Private Sub UserControl1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp, Label1.MouseUp, Label2.MouseUp
MsgBox("Event Fired")
End Sub

The labels Mouseup will call the code in this sub properly and the "Event Fired" will appear. In my form I have this code to look for the usercontrols mouseup:

Private Sub UserControl11_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles UserControl11.MouseUp
MsgBox("mouseup")
End Sub

The mouseup from the labels will not be sent to the form. If I click in the userControl outside the labels the msgbox for "Event Fired" goes and then the msgbox for "Mouseup". If I click one of the labels in the control then the "Event fired" will go but the "Mouseup" will not.

I need the mouseup from the labels to propagate to the form as a mouseup for the UserControl.

Anyone know how to do this?
 
Got the Answer from another message board.


Public Shadows Event MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)

Private Sub MyMouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp, Label1.MouseUp, Label2.MouseUp
RaiseEvent MouseUp(sender, e)
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top