Visual Basic中的Combobox和MaskedTextBox! [英] Combobox and MaskedTextBox in Visual Basic!

查看:202
本文介绍了Visual Basic中的Combobox和MaskedTextBox!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我有一个包含3个项目的组合框:产品尺寸和成本.
我还有一个maskedtextbox.

Well I have a combobox with 3 items namely: Product Size and Cost.
I have also a maskedtextbox.

推荐答案

再次问好!

由于您提出的是一个新问题,因此,我将在这里答复,而不是在您的留言中答复.

您已经知道如何启用和禁用MaskedTextBox:将MaskedTextBox.Enabled属性设置为true或false.

您的组合框是否包含产品,尺寸和成本的组合?
IE.用户可以选择的项目中是否包含所有排列?
Hello again!

Since you have raised this as a new question, I will reply here, rather than to your message(s).

You already know how to enable and disable the MaskedTextBox: set the MaskedTextBox.Enabled property to true or false.

Does your combo box contain combinations of Product, Size, and Cost?
I.e. do you have all the permutations in the Items the user can select?
Product
Size
Cost
Product and Size
Product and Cost
Size and Cost
Product, Size and Cost

如果是这样,那么最好的方法可能是通过Select语句:

If so, then probably the best way is via a Select statement:

Select Case cbOperation.SelectedText
    Case "Product", "Size", "Cost", "Product and Cost", "Size and Cost"
        tbCost.Enabled = False
        Exit Select
    Case "Product and Size", "Product, Size and Cost"
        tbCost.Enabled = True
        Exit Select
End Select


如果不是,则用户无论如何都无法选择组合...:laugh:

不起作用,亲爱的,我的代码如下:


If not, then the user can''t select a combination anyway... :laugh:

"Does not work dear, my codes below:

Private Sub cboType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboType.SelectedIndexChanged

Select Case cboType.SelectedText
            Case "Product", "Size"
         mtxtCategory.Enabled = False
                Exit Select

 Case "Cost"
         mtxtCategory.Enabled = True
                Exit Select
        End Select




阅读您的代码(并尝试一下,以便我意识到您需要强制转换)后,请尝试以下操作:




After reading your code, (and trying it so I realize you need a cast), try this:

Select Case DirectCast(cbOperation.SelectedItem, String)
    Case "Cost", "Product and Cost", "Size and Cost", Else
        tbCost.Enabled = True
        Exit Select
    Case "Product", "Size", "Product and Size", "Product, Size and Cost"
        tbCost.Enabled = False
        Exit Select
End Select



您确实意识到,如果组合框仅包含成本",产品"和尺寸"这三个项目,则不能选择产品和尺寸"或产品和成本"的组合,对吗?

顺便说一句:在西方社会,不鼓励使用亲爱的"作为敬语(如亲爱的,不要工作"),因为它带有性别歧视色彩.在这种情况下,我是男性,没有犯罪行为,但是您应该小心!



You do realise that if your combo box only has the three items "Cost", "Product" and "Size" you cannot select a combination of "Product and Size", or "Product and Cost", don''t you?

BTW: In western society, use of "dear" as an honorific (as in "Does not work dear,") is discouraged as it has sexist overtones. In this case I am male and take no offence, but you should be careful!


这篇关于Visual Basic中的Combobox和MaskedTextBox!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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