Solved

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

Posted on 2013-12-04
2
283 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 350 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

738 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