So this is my solution:
I handle TextChanged
event and inside this method I assign text
to its tag
:
Private Sub NUDTextChanged()
Integer.TryParse(NUD.Text, NUD.Tag)
End Sub
And then:
Private Sub NUD_LostFocus() Handles NUD.LostFocus
If NUD.Tag < NUD.Minimum Or NUD.Tag > NUD.Maximum Then
' show message
End If
End Sub
Handling Validating
event is useless for me because automatic change to allowed value is before validating and this automatic change fires TextChange
event so after validating I have new value instead invalid one.
LostFocus
is before automatic change so I can easily control if the value is valid or not.