Solved

Combo box with dual value list.

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.

828 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