Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / February 2005

Tip: Looking for answers? Try searching our database.

click event for the entire form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
KEMJ - 16 Feb 2005 19:53 GMT
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).

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.