禁止在TabControl的默认快捷键 [英] Disable default shortcuts on a TabControl
问题描述
<大骨节病>控制骨节病> + <大骨节病>上一页骨节病> / <大骨节病>下页骨节病>和<大骨节病>控制骨节病> + <大骨节病>标签骨节病>是默认的快捷键为TabControl的。他们帮助在相邻标签之间移动。我想<大骨节病>控制骨节病> + <大骨节病> pageX属性骨节病>行为只为外标签(TAB1,TAB2)携手<大骨节病>控制骨节病> + <大骨节病>标签骨节病>为内标签(TAB3,TAB4)时,我的重点是在控制(文本框在这里)的行为。对于这一点,我需要禁用默认行为。是否有某种方式来做到这一点?
Ctrl + PageUp/PageDown and Ctrl + Tab are default shortcuts for the TabControl. They help in moving between adjacent tabs. I would like Ctrl + PageX behaviour to work only for the outer tabs (tab1, tab2) and Ctrl + Tab behaviour for the inner tabs (tab3, tab4) when my focus is in the control (textbox here). For this, I need to disable the default behaviour. Is there some way to do this?
我看着ProcessDialogKey和IsInputKey,但他们似乎只与单个KEYDATA工作。修饰符不处理。
I looked at ProcessDialogKey and IsInputKey, but they seem to work only with single keydata. Modifiers are not handled.
推荐答案
的TabControl
有着不同寻常的键盘快捷方式处理,它们被反射到的onkeydown( )
方法。这样做是为了避免干扰键盘操作的控制选项卡页面上。
TabControl
has unusual keyboard shortcut processing, they are reflected to the OnKeyDown()
method. This was done to avoid it disturbing the keyboard handling for the controls on a tab page.
你必须要覆盖的方法。添加一个新类到您的项目并粘贴下面所示的code。编译。从工具箱顶新控制到你的表格
。
You'll have to override the method. Add a new class to your project and paste the code shown below. Compile. Drop the new control from the top of the toolbox onto your Form
.
using System;
using System.Windows.Forms;
class MyTabControl : TabControl {
protected override void OnKeyDown(KeyEventArgs e) {
if (e.KeyData == (Keys.Tab | Keys.Control) ||
e.KeyData == (Keys.PageDown | Keys.Control)) {
// Don't allow tabbing beyond last page
if (this.SelectedIndex == this.TabCount - 1) return;
}
base.OnKeyDown(e);
}
}
这篇关于禁止在TabControl的默认快捷键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!