What is an interface that specifies an enumerable Windows control?
-
23-08-2019 - |
Question
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!
Solution
ComboBox doesn't implement an interface, but instead inherits from the abstract class ListControl.
OTHER TIPS
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.