开发者

Catch a mouse click event on a control [duplicate]

This question already has answers here: Closed 11 years ago.

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

  1. handle control click event
  2. 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 
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜