Remember the validation event is oly triggered when focus is lost in a field i.e. when the user tries to move on to the next field or exit. If the validation fails the focus has to be returned to the field with the incorrect data in it.
If you want to highlight the text in the field you can use this after you set focus:
txtField.SelectionStart = 0
This piece of code puts the cursor at the start of the field.
txtField.SelectionLength = txtField.Text.Length
This piece of code sets the length of selection as the length of the text in the field, so it only selects that text and no more.
No comments:
Post a Comment