How do I set a click event for a form?

前端 未结 6 760
名媛妹妹
名媛妹妹 2021-01-05 10:37

I have a c# form (let\'s call it MainForm) with a number of custom controls on it. I\'d like to have the MainForm.OnClick() method fire anytime someone clicks on the form re

6条回答
  •  天命终不由人
    2021-01-05 11:09

    Catching a click on an open space on the form is easy, but to get a click that's actually on a control, you'll need the cooperation of that control to send it to the form.

    One possibility is to place a transparent control over the entire form, and accept clicks onto that, deal with them, and then pass them onto the proper control underneath.

提交回复
热议问题