What is the best way to validate a selected value in a ComboBox?

What is the best or preferred method to validate a value selected from a ComboBox. What are the best Events to use?

Thanks!
BlakeMcKennaAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Jacques Bourgeois (James Burger)Connect With a Mentor PresidentCommented:
Depends on what you intend to validate and how. Otherwise, you would not have all the choices that are offered.

SelectedIndexChanged is very often the best choice because it is triggered for every change of selection.

SelectedValueChanged might be better in some circumstances, specially if you have many entries in the list that ends up returning the same value. In such a case, moving between 2 such entries would not trigger the event.

And although I find it more useful in other controls such as a TextBox, Validating could also be considered because its e.Cancel parameter makes it easy to keep the cursor in the ComboBox without triggering a few other events when the validation falls flat.
0
 
BlakeMcKennaAuthor Commented:
So whatever Event uses the e validating argument, setting "e.Cancel = True" will keep the cursor in that control? Don't know why I never bothered to look that one up!

Thanks James
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.