如何检测“未填充”?文本框? [英] How do I detect a "non-filled" textbox?

查看:74
本文介绍了如何检测“未填充”?文本框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我正在尝试制作一个注册表,所以我有名字用户名密码等等,而我想要做的是:当人点击注册时,如果有任何文本框未填充,它将检测到它,并显示在msgbox中(确保您已完成所有案例)。谢谢你

hello, i'm trying to make a "registration form", so i have "name" "username" "password" and so on, and what i'm trying to do is: when the person clicks on " register", in case there is any textbox unfilled, it will detect it, and appear like in a msgbox("Make sure you have fulfilled all cases"). Thank you

推荐答案

从文本框的状态,你找不到用户从未修改过内容的文本框与文本框之间的区别。空字符串。用户可以有意识地添加一些文本然后删除它,如果它是相同的,你就不会发现这种情况和这个控件的初始状态之间的区别。



因此,为了更好地检测某些用户输入的存在,你需要在这个控件之外存储这些信息(任何类型的标志),比如说,在某些情况下,您的表单成员。您需要处理控件的已更改事件。在处理程序中,你应该修改这个外部标志。



使用的确切技术取决于你所说的VB和你使用的UI库。您可以通过阅读您使用的库上的文档轻松了解如何处理事件。







例如,您可能需要处理以下事件之一:

https://msdn.microsoft.com/en-us/library/system.windows.forms.control.textchanged%28v=vs.110%29 .aspx [ ^ ],

https://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.datacontextchanged%28v=vs.110%29.aspx [ ^ ]。



如果您正在使用其他东西(不是WPF,不是 System.Windows.Forms 或某些旧版本没有我引用的事件),你必须具体询问。



-SA
From the state of the text box, you cannot find difference between the text box which content was never modified by the user and the one with the text of empty string. The user could add some text and then delete it, consciously, and you would not detect the difference between this situation and the initial state of this control, if it is the same.

Therefore, for more fine-grain detection of the presence of some user input, you need to store this information (any kind of flag) outside of this control, say, in some instance member of your form. You would need to handle the "changed" event of the control. In the handler, you should modify this outside flag.

The exact technique to be used depends on what you mean by "VB" and what UI library you use. You can easily find out how to handle events, by reading documentation on the library you use.



For example, you may need to handle one of these events:
https://msdn.microsoft.com/en-us/library/system.windows.forms.control.textchanged%28v=vs.110%29.aspx[^],
https://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.datacontextchanged%28v=vs.110%29.aspx[^].

If you are using something else (not WPF, not System.Windows.Forms or some older version not having the event I referenced), you have to ask about it specifically.

—SA


这篇关于如何检测“未填充”?文本框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆