[英]How to avoid selecting textbox value when press Enter?
Control nextControl;
if (e.KeyCode == Keys.Enter)
{
nextControl = GetNextControl(ActiveControl, !e.Shift);
if (nextControl == null)
{
nextControl = GetNextControl(null, true);
}
nextControl.Focus();
e.SuppressKeyPress = true;
}
I have this code to act ENTER Key as TAB but when I press Enter key it is selecting textbox value as in image我有这段代码可以将 ENTER 键用作 TAB,但是当我按 Enter 键时,它正在选择文本框值,如图
You can tell the TextBox to select nothing您可以告诉 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;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.