开发者

Problems with keys on winform and focus

开发者 https://www.devze.com 2023-01-10 11:26 出处:网络
My winform window was working fine then i added a combobox to it. Now my code which uses theform_KeyDown does not work. From my understanding when it gets focus it gives it to my combobox thus my wind

My winform window was working fine then i added a combobox to it. Now my code which uses theform_KeyDown does not work. From my understanding when it gets focus it gives it to my combobox thus my window keydown event never happens? I had pictureboxes and no matter where i clicked i was able to use the keys nicely.

开发者_StackOverflow中文版

How do i allow keys to work again painlessly? it seems like i need to modify all the forms setfocus or add key events for this to work again. What is the easiest way?

I asked a focus question before so the answer may help give ideas but probably not


Once a form contains a child control that can receive the focus (in other words, not a picture box) then the form can no longer receive the focus. And thus won't get keyboard messages anymore, they'll go to the control with the focus. A quick fix is to set the form's KeyPreview property to True.

0

精彩评论

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

关注公众号