How to get Keypress event in Windows Panel control in C#

后端 未结 4 1331
挽巷
挽巷 2021-02-20 12:37

i want to get keypress event in windows panel control in c#, is any body help for me...

4条回答
  •  盖世英雄少女心
    2021-02-20 13:13

    The problem is, that at first your main form got the KeyPress and will immediately send this message to the active control. If that doesn't handle this key press it will be bubbled up to the parent control and so on.

    To intercept this chain, you have to in your Form.KeyPreview to true and add an handler to Form.KeyPress. Now you can handle the pressed key within your form.

提交回复
热议问题