Tab不会触发keydown或keypress事件 [英] Tab will not fire keydown or keypress event
问题描述
我在一个网络表单中工作,并有一个带有标签栏的表单。每个标签都有多个文本框。我有选项卡索引增量,从每个选项卡的1开始。如果用户点击表单的末尾和击中选项卡,我想从选项卡到选项卡。
I am working in a webform and have a form with a tab bar on it. Each tab has multiple text boxes in it. I have the tab indexes incremented, starting with 1 for each tab. I want to tab from tab to tab if the user hits the end of the form and hits tab.
我使用leave方法并更改了标签控件的选项卡,唯一的问题是如果我没有打标签,并说我点击到该选项卡上的另一个控件仍将拍摄到新标签页。
I used the leave method and changed the tabs for my tab control the only problem is if I didn't hit tab and say I click to another control on that tab it will still shoot over to the new tab.
我想方法来解决这个问题是听tab键按下,如果按键是tab离开然后改变窗体的其他选项卡,我只是不能似乎得到它的工作,但。我已经尝试与按键和键下降,但都不会拿起那个标签作为键。
I figure a way to solve this would be to listen for the tab key press and if the key press is tab on leave then change the form to the other tab, I just can't seem to get it to work though. I have tried with keypress and keydown but neither will pick up that tab as a key. If I was to say click or hit start typing it will trigger the events but tab will not.
有任何建议吗?
我已经尝试过这些事件,甚至没有一个事件会触发。
I have tried these and none of these event would even trigger.
private void afsiTxtDaysForTempOEpriceOverrides_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 11)
{
afsiTxtDaysForTempOEpriceOverrides_Leave(sender, e);
}
}
private void afsiTxtDaysForTempOEpriceOverrides_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == "11")
{
afsiTxtDaysForTempOEpriceOverrides_Leave(sender, e);
}
}
private void afsiChkSalesBaseCostUpdate_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 11)
{
afsiChkSalesBaseCostUpdate_Leave(sender, e);
}
}
private void afsiChkSalesBaseCostUpdate_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == 11)
{
afsiChkSalesBaseCostUpdate_Leave(sender, e);
}
}
编辑:发现页面使用UltraWinTabControl
Found out that the page is using UltraWinTabControl from Infragistics so maybe this is causing some issues with the tabbing.
推荐答案
我最终需要重写ProcessCmdKey现在我面对一个新的问题这是一种相关但不是特别的,所以我会添加它作为评论,如果我得到我的答案。
I ended up needing to override ProcessCmdKey now I face a new problem that is kind of related but not particular to this so I will add it as a comment if I get my answer.
private bool isTab = false;
private bool isShiftTab = false;
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Tab)
{
isTab = true;
ShiftTab.Append("Tab");
}
else
{
isTab = false;
}
return base.ProcessCmdKey(ref msg, keyData);
}
这篇关于Tab不会触发keydown或keypress事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!