遮罩文字框问题 [英] Mask Text Box problems

查看:151
本文介绍了遮罩文字框问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个组合框,文本框,numericUpDown和masktextbox.我希望填充所有这些内容,以便使用

I have a combobox, textbox, numericUpDown and a masktextbox. I want all these to be filled so that a

推荐答案

这是因为Text属性包含了用户应该填写的被屏蔽"字符.
尝试 MaskedTextBox.MaskCompleted [


是的,MaskCompleted是一个布尔值,因此您必须照此进行检查.
如果已禁用它,则需要将其检查添加到表达式中.

It''s because the Text property includes the "masked out" characters that the user is expected to fill in.
Try the MaskedTextBox.MaskCompleted[^] property instead.


"i did mtxtime.maskcompleted = false and it works
but the problem, i have a combobox where a specific item is selected, the masktextbox should be disabled automatically. however, when im doing what you told me, it is not letting me save now as it is recognising that the masttextbox is blank even disabled.
Enter your reply below and click the Submit button."



Yes, MaskCompleted is a bool, so you have to check it as such.
If you have disabled it, then you need to add the check for that into your expression.

If cboselect.SelectedIndex = -1 Or nuddigits.Value = 0 Or String.IsNullOrEmpty(textbox1.Text) Or Not mxttime.Enabled Or Not mxTtime.MaskCompleted Then




不一样.好的,我会解释清楚.
我有一个组合框,其中有3个项,分别是红色,蓝色,黑色和绿色.选择红色"或蓝色"时,将禁用masked文本框,否则将为其他颜色启用它.
当我选择红色或蓝色的MaskedTextBox中被禁用,不错,但问题是我选择了这些颜色时,仍然can''t保存因为即使残疾人,我得到的消息框,提示我去填满它.



所以?这只是在if条件下使逻辑正确的一种情况:




"No its the same. Ok, I will explain well.
I have a combobox which has 3 items namely Red, Blue, Black and Green. When Red or Blue is selected, the maskedtextbox is disabled else it is enabled for the other colours if selected.
when I select Red or Blue, the maskedtextbox is disabled, good, but the problem is I still can''t save as even disabled when selected these colours, i get the message box to prompt me to fill it."



So? That''s just a case of getting the logic right in your if condition:

If cboselect.SelectedIndex = -1
   Or nuddigits.Value = 0
   Or String.IsNullOrEmpty(textbox1.Text)
   Or (mxttime.Enabled And Not mxTtime.MaskCompleted)
Then

(我把行打断了,所以您可以更轻松地看到它们)

(I broke the lines up so you can see them a bit more easily)


也许其中有空格?您可以尝试textbox1.Text.Trim = ""看看是否可行.

如果它不起作用,请尝试调试并查看每个文本框中实际上是什么值.您应该能够从那里找到解决方案.
Perhaps it has a space in it? You could try textbox1.Text.Trim = "" and see if that works.

If it doesn''t work, try debugging and taking a look at what value IS actually in each textbox. You should be able to figure out a solution from there.


这篇关于遮罩文字框问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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