5个字符后切换
我正在尝试刷卡,输入 5 个字符后我希望它转到下一个文本字段。我正在扫描卡片。
目前我有:
private void membernumber1_TextChanged(object sender, EventArgs e)
{
}
但这在输入一个字符后立即改变它,有没有办法让它在输入 5 个字符后切换?
I'm trying to swipe a card and after the 5 characters are entered I want it to go to the next textfield. I'm scanning a card.
Currently I have:
private void membernumber1_TextChanged(object sender, EventArgs e)
{
}
But this changes it right after it enters one character, is there anyway to make it switch after 5 characters entered?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需计算
Text
属性中的字符数即可。如果他们使用退格键,则使用计数器将不起作用。但请注意,这可能不适用于粘贴到控件中的文本(即,如果它大于 5 个字符)。对于这种情况,您需要进行适当的验证,或者您可以禁用粘贴,但验证是更好的选择,因为肯定还有其他限制,例如全部为数字。
Just count the number of characters in the
Text
property. Using a counter won't work if they use the backspace key.Be aware though that this may not work for text that was pasted into the control (i.e., if it was > 5 characters). You'll need proper validation for that case or you can just disable pasting, but validation is preferable as there are certainly other restrictions like being all numeric.