To make this simple,
suppose I have a form (frmMain) with 2 groupboxes (gbx1 and gbx2). I know
if I click on gbx1 it will raise a gbx1_click_event, if I click on gbx2 it
will raise a gbx2_click_event, and if I click on the form anywhere where
the groupboxes are not it will raise a form_click_event. Is there a way
to raise some type of click event that doesn't care where I click, it just
returns the event arguements? I could then use the returned click
coordinates and calcualte what was clicked on (gbx1, gbx2 or the form).
Troy - 16 Feb 2005 20:42 GMT
Sort of, but you have to hook it up yourself to each control. Use the
AddHandler to hook all Click events (for each control you want to trap it
for). Be sure to get rid of the Actual handler you may have present or both
will fire!
Here's an example:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
AddHandler Me.Click, AddressOf ClickHandler
AddHandler GroupBox1.Click, AddressOf ClickHandler
End Sub
Private Sub ClickHandler(ByVal sender As Object, ByVal e As
System.EventArgs)
'Do work here
End Sub
'Get rid of the Previous Handlers!
'Private Sub GroupBox1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles GroupBox1.Click
'End Sub
'Private Sub Form1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Click
'End Sub

Signature
Troy
Troy Munford
Development Operations Manager
FMS, Inc.
www.fmsinc.com
To make this simple,
suppose I have a form (frmMain) with 2 groupboxes (gbx1 and gbx2). I know
if I click on gbx1 it will raise a gbx1_click_event, if I click on gbx2 it
will raise a gbx2_click_event, and if I click on the form anywhere where
the groupboxes are not it will raise a form_click_event. Is there a way
to raise some type of click event that doesn't care where I click, it just
returns the event arguements? I could then use the returned click
coordinates and calcualte what was clicked on (gbx1, gbx2 or the form).
joeycalisay - 17 Feb 2005 03:27 GMT
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.windowsfor
ms/browse_thread/thread/1fb87ed7d0299f05/544adb79241d8b49?q=How+to+capture+UserC
ontrol+mouse+events+in+it%27s+container&_done=%2Fgroup%2Fmicrosoft.public.dotnet
.framework.windowsforms%2Fsearch%3Fgroup%3Dmicrosoft.public.dotnet.framework.win
dowsforms%26q%3DHow+to+capture+UserControl+mouse+events+in+it%27s+container%26qt
_g%3D1%26searchnow%3DSearch+this+group%26&_doneTitle=Back+to+Search&&d#544adb792
41d8b49

Signature
Joey Calisay
http://spaces.msn.com/members/joeycalisay/
> To make this simple,
> suppose I have a form (frmMain) with 2 groupboxes (gbx1 and gbx2). I know
[quoted text clipped - 4 lines]
> returns the event arguements? I could then use the returned click
> coordinates and calcualte what was clicked on (gbx1, gbx2 or the form).