如何截取TAB键preSS在C#prevent标准焦点变化 [英] How to intercept the TAB key press to prevent standard focus change in C#
问题描述
通常,当pressing焦点更改到指定的Tab键顺序的下一个控件TAB键。我想prevent而拥有TAB键做别的事情。就我而言,我想从一个组合框更改焦点到一个完全不同的控制。我不能设置Tab顺序做到这一点。我需要以编程方式做到这一点。任何想法如何?这似乎是KeyDown和关键preSS事件不能正确处理TAB键。 谢谢你。
Normally when pressing the TAB key you change the focus to the next control in the given tab order. I would like to prevent that and have the TAB key do something else. In my case I'd like to change focus from a combobox to a completely different control. I can't do this by setting the tab order. I need to do this programatically. Any idea how? It seems like the KeyDown and KeyPress events can't handle TAB key correctly. Thanks.
推荐答案
覆盖 ProcessDialogKey
或 ProcessTabKey
窗体上和你要取决于其控制的重点是逻辑。
Override ProcessDialogKey
or ProcessTabKey
on your Form and do the logic you want depending on which control is focused.
这篇关于如何截取TAB键preSS在C#prevent标准焦点变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!