Solved

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

Posted on 2013-12-04
2
279 Views
Last Modified: 2013-12-05
What is the best or preferred method to validate a value selected from a ComboBox. What are the best Events to use?

Thanks!
0
Comment
Question by:BlakeMcKenna
2 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 350 total points
Comment Utility
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
 

Author Comment

by:BlakeMcKenna
Comment Utility
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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now