CCheckComboBox: A ComboBox with a Checked Tree Dropdown
Click here for larger image
Environment: VC6, Windows 98, 2000, NT4
Often programmers meet situations when it is necessary to filter data based on a number of criteria. A solution is to implement a number of simple combos or checklist boxes. This has the disadvantage of not allowing multiple choices (combos) or taking a lot of space (checklist boxes).
I wanted a control with both the functionality of a combo and of a tree with checkboxes. Such a control would act like a combo showing a dropdown, and also allowing multiple selections, and fast selection or deselection of all items.
I saw on CodeGuru other ideas, which are more or less close to what I expected from such a control but I think they lack functionality in a way or another, so I decided to write my own solution.
User keys: alt + up or down, F4 (to drop/close the dropdown) up, down (to move the selection up or down), right (to expand current item), left (to collapse current item) and space (to check or uncheck the current item).
Using CCheckComboBox: For example if you want to add 3 countries: "USA" (ID=5), "Canada" (ID=6), "UK" (ID=7), and their corresponding continents, you would have to write the following code:
//## ADD tree items: m_choCountries.AddString("North America"); m_choCountries.AddString("USA", 5, ROOT_LEVEL + 2); m_choCountries.AddString("Canada", 6, ROOT_LEVEL + 2); m_choCountries.AddString("Europe"); m_choCountries.AddString("UK", 7, ROOT_LEVEL + 2); //## CHECK all items m_choCountries.CheckAll(TRUE); //## UNCHECK the item with ID = 6 m_choCountries.SetCheck(6, FALSE); //## GET all checked items CString strCheckedItems = m_choCountries.GetCheckedIDs();

Comments
I found many mistakes
Posted by zizzzz on 11/02/2006 07:38amlike 'CTreeCtrl::CreateEx'B_: don't deaserve 8 parameters
-
Replyerror
Posted by zlristovski on 04/18/2009 06:32amAnd anyone who fix tis problem with 8 parameters
ReplyDebug Error in vs 2005 bate2
Posted by paraGOD on 10/25/2005 04:01amHi guys, when I use this source code in vs2005,Assert error occured.The following is the code:ASSERT((dwStyle & WS_POPUP) == 0); Can someone give me some help?thanks para
-
ReplyRe: Debug Error in vs 2005 bate2
Posted by creeh on 07/10/2006 07:44amHi I am getting the same Assert error and wondered if you found a solution to it. The functionality seems to work fine, it is just asserting. Chris
ReplyNice work!
Posted by Legacy on 12/22/2003 12:00amOriginally posted by: miro kundacina
very very nice work,
Replythank you.
kmiro, kmiro@narat.co.yu
Error in using in MDI window
Posted by Legacy on 03/17/2003 12:00amOriginally posted by: mask
-
ReplyError also by using the control in multiple dialogs
Posted by oystein on 04/28/2004 04:44amHi, I get exactly the same problems as you Mask, when using forms. I also tried to reproduce the error using an extra dialog in the demoproject. 1: Use the demoproject as it is 2: Add a test-button in the SampleDlg 3: Make a new simple test-dialog with one CCheckComboBox item, and connect this to the test-button. 4: Run the project, and i.e uncheck europe from the "Countries" CheckComboBox. 5: Push the test-button, the test-dialog will now freeze.. At first I thought this code was excactly what I was looking for, but it seems to be unable to use in my project because of this problem. If anyone can help me, I will be very thankful! Regards Oystein
ReplyWhat about shift one place up and down functionality
Posted by Legacy on 02/24/2003 12:00amOriginally posted by: gracias carol
hi it looks to me that u have done good work in tree control , i am looking for adding the right click menu pop up option of shift up and shift down on the selected node of tree control. Need help on it right now my cut/copy/paste/drag/drop are working fine.
Waiting for an reply
Replygracias
Nice work!
Posted by Legacy on 01/18/2003 12:00amOriginally posted by: Ahmed Ceder
Nice work ..
I was looking for something like this.
thanx a lot.
Reply
Anyone convert this to COM?
Posted by Legacy on 01/03/2003 12:00amOriginally posted by: mburt
I have need for this control, but in a VB environment.
ReplyHas anyone attempted converting this class to a COM object?
A ComboBox with a Checked Tree Dropdown
Posted by Legacy on 12/19/2002 12:00amOriginally posted by: prabir
ReplyIs there a reason to parent the treectrl to the desktop
Posted by Legacy on 12/09/2002 12:00amOriginally posted by: Glen Smith
Very good job, Simple but effective. l just was wondering why the tree control is parented to the destop and not the dialog?
Replyhow to rewrite it with c#?
Posted by Legacy on 11/01/2002 12:00amOriginally posted by: sunhs
you have done an excellent job,but how to rewrite it with c#?
ReplyLoading, Please Wait ...