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

后端 未结 4 1334
挽巷
挽巷 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:21

    You should handle the Panel.KeyPress event.

    Example

    public void MyKeyPressEventHandler(Object sender, KeyPressEventArgs e)
    {
        ... do something when key is pressed.
    }
    
    ...
    
    (MyPanel as Control).KeyPress += new KeyPressEventHandler(MyKeyPressEventHandler);
    

提交回复
热议问题