Control nextControl;
if (e.KeyCode == Keys.Enter)
{
nextControl = GetNextControl(ActiveControl, !e.Shift);
if (nextControl == null)
{
nextControl = GetNextControl(null, true);
}
nextControl.Focus();
e.SuppressKeyPress = true;
}
我有这段代码将 ENTER 键用作 TAB,但是当我按 Enter 键时,它正在选择图像中的文本框值
最佳答案
您可以告诉 TextBox 不选择任何内容
Control nextControl;
if (e.KeyCode == Keys.Enter)
{
nextControl = GetNextControl(ActiveControl, !e.Shift);
if (nextControl == null)
{
nextControl = GetNextControl(null, true);
}
nextControl.Focus();
TextBox box = nextControl as TextBox;
if (box != null)
box.Select(box.Text.Length, 0);
e.SuppressKeyPress = true;
}
关于c# - 按Enter键时如何避免选择文本框值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30950454/