什么是指定可枚举 Windows 控件的接口?

发布于 2024-07-16 12:08:57 字数 668 浏览 9 评论 0原文

我有一个验证组合框控件的方法,如下所示:

Public Function ValidateComboBox(ByVal objMessageMode As Errors.MessageMode, ByVal cboInput As ComboBox) As Boolean

    Dim blnValidated As Boolean

    'no value--invalidate'
    If cboInput.SelectedValue Is Nothing Then
        Errors.InvalidateField(cboInput, Errors.errFieldBlank, Me.ErrorProviderPurchaseTag, objMessageMode)
        blnValidated = False

        'value--validate'
    Else
        Errors.ValidateField(cboInput, Me.ErrorProviderPurchaseTag)
        blnValidated = True
    End If

    Return blnValidated

End Function

我想要的是能够替换任何控件作为实现“SelectedValue”对象行为的参数。 有我可以指定的接口吗? 谢谢您的帮助!

I have a method that validates a combo box control like so:

Public Function ValidateComboBox(ByVal objMessageMode As Errors.MessageMode, ByVal cboInput As ComboBox) As Boolean

    Dim blnValidated As Boolean

    'no value--invalidate'
    If cboInput.SelectedValue Is Nothing Then
        Errors.InvalidateField(cboInput, Errors.errFieldBlank, Me.ErrorProviderPurchaseTag, objMessageMode)
        blnValidated = False

        'value--validate'
    Else
        Errors.ValidateField(cboInput, Me.ErrorProviderPurchaseTag)
        blnValidated = True
    End If

    Return blnValidated

End Function

What I want is to be able to substitute any control as a parameter that implements the behavior of the "SelectedValue" object. Is there an interface that I could specify? Thanks for the help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鯉魚旗 2024-07-23 12:08:57

ComboBox 不实现接口,而是继承自抽象类 ListControl

ComboBox doesn't implement an interface, but instead inherits from the abstract class ListControl.

忆梦 2024-07-23 12:08:57

我不相信有。 我创建了自己的接口(通常是 I(Product)Field,还包含其他帮助信息),每种不同类型的控件都实现该接口。 然后,在验证中我只是将其转换为该值; 它不是世界上最好的设计,但它却很有魅力。

请注意,这还涉及对每种类型的控件(编辑框、组合框等)进行子类化,但是,我通常已经出于其他目的对它们进行了子类化,所以我不认为这是一个问题。

I don't believe there is. I've created my own interface (usually I(Product)Field that also contains other helper info) that each different type of control implements. Then, in the validation I just cast to that; it's not the best design in the world but it works like a charm.

Note that this also involves subclassing each type of control (edit box, combo box, etc) but, I'm usually already subclassing them for other purposes so I don't consider this is a problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文