Solved

visual studio 2008 c++ combobox similar entries

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now