Solved

Combo box with dual value list.

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

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