Catch a mouse click event on a control [duplicate]
Possible Duplicate:
Handling a Click for all controls on a Form
I have a user control, I add controls on this user control. All of children will cover user control' region. That mean, you don't have any space to click on user c开发者_JAVA百科ontrol.
My problem how to detect user mouse click on this user control's region.
Please give me the best solution without add mouse click event handler on each child to detect mouse click. Thanks.
As per you can do following
- handle control click event
- in that event check the sender -- its of your control type
This will do your task
For Example -- here I am handling button click event (you can handle click event of your control)
private void button1_Click(object sender, System.EventArgs e)
{
if(sender is Button)//MyControl in you case
{
//your code
}
}
精彩评论