Solved

visual studio 2008 c++ combobox similar entries

Posted on 2009-03-31
4
1,625 Views
Last Modified: 2013-12-14
I have a combo box for a uni assignment that contains a number of last names. Some names (ie text) are identical but the values are different. I am currently using an arraylist of objects to construct a dataset and then nominating the displaymember & valuemembers

The SelectionChangeCommitted event allows me to correctly identify which item is selected

However, I can't figure out how to get the same results if the user enters text. The duplicate entries cause are not being selected properly
0
Comment
Question by:PhillO
  • 2
  • 2
4 Comments
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 24030748
You better would use a list control with two (or more) columns where you could add the first name or student ID as a second attribute so that the entry is unique then.

If the combobox is a requirement you would need to add the first name (or ID) either. If the edit part of the combobox is enabled for new entries, the user would need to add the additional attribute as well, or - in case of an ID - you would add the next free ID number programmatically when the edit part of the combobox was used (the GetCurSel would return -1 then).

0
 

Author Comment

by:PhillO
ID: 24034793
Whilst a name maybe duplicated, the value itself is a uique ID. The SelectionChangeCommitted event works and returns the correct SelectedValue. This is fine when the user clicks the combobox and selects an entry from the drop down list.

However, when you use the keyboard to start entering the name, use the arrow keys to select the entry, then use the tab key/Enter key to select the entry, SelectionChangeCommitted event does not seem to be triggered.

Essentially the problem is how to handle entries with identical display, different values I understand that a ListBox behaves the same
0
 
LVL 39

Accepted Solution

by:
itsmeandnobodyelse earned 500 total points
ID: 24199681
>>>>> Essentially the problem is how to handle entries with identical display

No. It is wrong to display entries with same name in a combobox. If the user can use the edit field to add new entries you need to assure that it is a new name before adding it to the list of entries. To make it comfortable you simply could set the item as selected if an existing name was entered.
0
 

Author Comment

by:PhillO
ID: 24200168
Thanks for your assistance

Phill
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Login 17 50
SQL Exceptions 3 43
Entity Framework 7 41
VB: Convert 2 dates to specific format 24 48
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

786 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