Combobox Validating - on value changed?

PhillD

Well-known member
Joined
Mar 5, 2010
Messages
91
Programming Experience
10+
Hi,

Is it possible to only validate a combobox if it's value is changed? I'm looking for something similar to the .modified property of the textbox countrol.

VB.NET:
Private Sub txtCheckNumber_Validating(sender As System.Object, e As System.ComponentModel.CancelEventArgs) Handles txtCheckNumber.Validating

        'only run validation if the check number is changed.
        If txtCheckNumber.Modified = True Then
            ValidateData()
        End If

    End Sub


The problem I have is the combobox validating event run's every time you tab through the control regardless of whether the underlying value has changed. This is really causing me some problems.

I can't use SelectedValueChenged or SelectedIndexChanged because they do not trigger when the user enters a value that is not in the underlying combobox dataset. Due to some weird business issues, the users must be able to free entry into the combo box.

Can anyone help me with this.
 
The ComboBox has no such property but there's nothing to stop you creating a custom control that inherits ComboBox and adds one. VB.NET is an OO language so make use of that. It would be False by default and you could override the OnSelectedIndexChanged or OnSelectionChangeCommitted method and the OnTextChanged method to set it to True and the OnValidated method to set it back to False.
 
Back
Top