Solved

visual studio 2008 c++ combobox similar entries

Posted on 2009-03-31
4
1,632 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
[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
  • 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

A new era in Cloud training has arrived.

A day that will go down in Cloud history.. But are you ready for it? Will you accept this Cloud challenge?

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

635 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