Solved

Combo box with dual value list.

Posted on 1998-08-12
1
227 Views
Last Modified: 2013-11-20
Hi

I need to implement a combo box derived class which can support a pair of lists (values) to be shown
when it is clicked  upon.  Which of the the list from a pair is shown is to be controlled by a flag.  

For e.g. Say the first list contains entries like USA, UK, Russia, Germany, France.
(When you expand combo box you will see each of the five countries as separate possible value.)
Second list will contain values like USA, UK, Russia, Germany, France, India, Pakistan, China.
First list will always be subset of the second list.

Which of the two value shows up is simply controlled by boolean flag.
If flag set to True, it  will show the first list in the pop up box else it will show the second list set.

I want to avoid having to maintain two pairs of list and changing the combo box contents everytime.
Among other things it might screw up other part of code that depend upon the index/position of value
on the list.

0
Comment
Question by:SamratAshok
1 Comment
 

Accepted Solution

by:
lsean earned 100 total points
ID: 1320694
1) Derive a class from CComboBox, add a member variable of type CStringArray to contain those strings in the second list but not in the first list. Add another member varible of type BOOL to represent the flag you mentioned.

2) After the combobox is created, insert the first list into the combobox, and insert the second list into the CStringArray varible.  Initialize the flag to FALSE.

3) Add a member function AddExtraStrings() that inserts strings in the CStringArray member varible into the combobox.  Add another function RemoveExtraStrings() to delete strings in the CStringArray member varible from the combobox.

4) Whenever the flag changes to TRUE, call the AddExtraStrings() function. Whenever it changes to FALSE, call the RemoveExtraStrings() function.

5) Don't use the "sort" style if the order of strings in the combobox is important to you.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
lucky13 challenge 11 124
fizzArray2 challenge 1 72
wordcount challenge 11 109
Excel file not created as expected 7 50
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

867 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

22 Experts available now in Live!

Get 1:1 Help Now