Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

visual studio 2008 c++ combobox similar entries

Posted on 2009-03-31
4
Medium Priority
?
1,633 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 2000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

670 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