gpt4 book ai didi

C# 禁用 TAB 键

转载 作者:太空宇宙 更新时间:2023-11-03 18:00:54 24 4
gpt4 key购买 nike

我有这个代码:

this.searchInput.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.inputKeypress);

私有(private)无效按键(对象发送者,KeyPressEventArgs e)
{
//如果 Tab 已经被按下
if(122 == (int)e.KeyChar)
{
switchTab(sTab);
MessageBox.Show(sTab);
}
}

它的作用是将焦点集中在另一个元素上。
但是,当焦点设置为 TextBox 时,我按 TAB 键,它只会在 TextBox 中创建一个选项卡,而不会将焦点设置在下一个元素上。

任何人都知道我怎样才能使这项工作?

我试图设置 e.Handled = true;但这没有用...

最佳答案

你试过设置AcceptsTabTextBoxfalse ?

编辑:

yep. It does not work. Strange... It still tabulates in the textbox



这没什么意义。我运行了一个小型测试应用程序,tab 键只会将焦点从 TextBox 上移开。当它的 AcceptsTabMultiline属性都是 true ,无论是否为 KeyPress 定义了事件处理程序.

您确定没有设置其他代码 AcceptsTabtrue ?如果是,设置 Multilinefalse完全改变标签行为?您能否发布更多相关代码?

关于C# 禁用 TAB 键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1468835/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com