Click here to Skip to main content
13,404,408 members (39,855 online)
Click here to Skip to main content
Add your own
alternative version


49 bookmarked
Posted 31 Jul 2002

Store and show Tree struct in a Combobox

, 31 Jul 2002
Rate this:
Please Sign up or sign in to vote.
Store and show Tree struct in Combobox

Sample Image - CWzCombox.gif


I am working in a CAPP project which based on database. We often use combo-box to show all table in database to user and let user select a table, it's a simple way, not only for the user but also for coder. In some condition, there is special relationship between one table and another table, the simple combo-box can't describe it. I write a new class to deal with this condition.

I use a struct to store the relationship between items (tables):

typedef struct tagITEMDATA
    WORD wParantOriginIdx; //the root item's parent is nRootIndex
    WORD wOriginIdx; //Original index when first insert to listbox
    BYTE cType;
    BYTE cLevel;
  • wParantOriginIdx is the item's parent original index (the index when it was first insert to combo-box), the index of items may change when you add or delete items, so we should keep it.
  • wOriginIdx is item's original index.
  • cType mark the item type, maybe use for other special .
  • cLevel is the level of items, children level is higher than parents.

This struct is the core of CWzCombox class, please check source code for detail.


This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


About the Author

Software Developer (Senior)
China China
I had graduated from HuaZhong University of Science & Technology. Now, I'm working in ZTE.

You may also be interested in...

Comments and Discussions

GeneralVery useful code ! Pin
Nice Gom18-Jan-11 14:31
memberNice Gom18-Jan-11 14:31 
GeneralImplementation in C/C++ using the Win32 API Pin
hcraes4-Nov-09 8:16
memberhcraes4-Nov-09 8:16 
GeneralSame thing in C# Pin
101629-Jan-09 1:48
member101629-Jan-09 1:48 
Very very good and according to my deeds the combobox. Thanks for implementing it.

My problem is I am using C#. Can any body tell me the same thing in C#? I have got other samples too but they use just show/hide tree view. it does not appear as drop-down like Simon.W has implemented. Please guide me the same thing in C#.

Bundle of thanks in advance
QuestionItem Data Pin
blackbondi7-Jan-08 3:18
memberblackbondi7-Jan-08 3:18 
AnswerRe: Item Data Pin
Apollo_Apollo18-Jun-08 17:50
memberApollo_Apollo18-Jun-08 17:50 
General1 question Pin
VC Spark20-Jun-07 2:06
memberVC Spark20-Jun-07 2:06 
GeneralRe: 1 question Pin
Simon.W26-Jun-07 5:32
memberSimon.W26-Jun-07 5:32 
GeneralRe: 1 question Pin
VC Spark4-Jul-07 4:04
memberVC Spark4-Jul-07 4:04 
GeneralThank you Pin
johnxie28-Sep-06 21:06
memberjohnxie28-Sep-06 21:06 
GeneralVery good. One thing to keep in mind though Pin
strtdusty7-Mar-05 11:38
memberstrtdusty7-Mar-05 11:38 
Questionvery question? Pin
vivadotnet20-Jun-04 17:57
membervivadotnet20-Jun-04 17:57 
GeneralExcellent! Pin
Dominik Reichl2-Jul-03 9:55
memberDominik Reichl2-Jul-03 9:55 
GeneralUseful tool Pin
David Spain6-Aug-02 5:12
memberDavid Spain6-Aug-02 5:12 
GeneralRe: Useful tool Pin
XSimon13-Aug-02 16:16
memberXSimon13-Aug-02 16:16 
GeneralPretty Good!! Pin
WREY5-Aug-02 10:07
memberWREY5-Aug-02 10:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.1802120.2 | Last Updated 1 Aug 2002
Article Copyright 2002 by Simon.W
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid