Tree ComboBox Control

Introduction

Recently, I needed a tree control inside a combobox, and during my search on Google I found something, but it was a little more complicated than I required. I started to draft one myself, and am sharing the result with you.

Using the Code

Everything is based on CTreeComboBox, which is derived from the standard CComboBox. Here I have a CComboTreeCtrl variable member and methods characteristic to a tree control. In CTreeComboBox::PreSubclassWindow, I create and initialize m_Tree and stretch on the combobox dropdown list.

In order to use this control, you need #include "TreeComboBox.h" and further handle combobox like it is a tree control (you can see how in the sample project).

Enjoy it!

History

26 April, 2011: Initial version.

20 February, 2012: Added CTreeCtrl and GetTreeCtrl() methods to the CTreeComboBox class, so now it has full access to the tree control.

10 May, 2013: Updated the control archive.

16 Oct., 2014: The drop down is dropped by screen position (down or up); The drop down can not be closed by Alt+F4.

14 Nov. 2014: I updated the code in order to be used on newer versions of Visual Studio (VS2008 for instance).

18 Nov. 2014: I added posibility that combobox could be dropped down through F4. I added CComboTreeCtrlExt class in order to be customized tree control of combobox without mess up CComboTreeCtrl class.

Unfortunately , I didn't work in VS2008 , ( I never use this environment ) , so I try your solution in VC6 but didn't working ... I will study the issue and I hope to come back with a solution . Thanks for feedback .