Solved

Combo box with dual value list.

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

622 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