Solved

visual studio 2008 c++ combobox similar entries

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

752 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