?
Solved

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

Posted on 2013-12-04
2
Medium Priority
?
287 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 1400 total points
ID: 39697241
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
ID: 39698227
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

650 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