Solved

Combo box with dual value list.

Posted on 1998-08-12
1
237 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
[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
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Best tools for Backup and restore of Wordpress site 6 58
MaxSpan challenge 9 138
changeXy challenge 13 96
Is there a simple front-end menu system. 9 145
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

739 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