Click here to Skip to main content
Click here to Skip to main content

Store and show Tree struct in a Combobox

By , 31 Jul 2002
 

Sample Image - CWzCombox.gif

Introduction

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;
}ITEMDATA,*LPITEMDATA;
  • 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.

License

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

About the Author

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

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralVery useful code ! PinmemberNice Gom18 Jan '11 - 13:31 
GeneralImplementation in C/C++ using the Win32 API Pinmemberhcraes4 Nov '09 - 7:16 
GeneralSame thing in C# Pinmember101629 Jan '09 - 0:48 
QuestionItem Data Pinmemberblackbondi7 Jan '08 - 2:18 
AnswerRe: Item Data PinmemberApollo_Apollo18 Jun '08 - 16:50 
General1 question PinmemberVC Spark20 Jun '07 - 1:06 
GeneralRe: 1 question PinmemberSimon.W26 Jun '07 - 4:32 
GeneralRe: 1 question PinmemberVC Spark4 Jul '07 - 3:04 
Ok,I got the answer in this article
http://www.codeguru.com/cpp/controls/combobox/dropdown/article.php/c4947/[^]
 
I need it for make the items in categories and sorting them in each category with suppressing the main nodes (categories names) click.
thanx anyway
GeneralThank you Pinmemberjohnxie28 Sep '06 - 20:06 
GeneralVery good. One thing to keep in mind though Pinmemberstrtdusty7 Mar '05 - 10:38 
Questionvery nice...one question? Pinmembervivadotnet20 Jun '04 - 16:57 
GeneralExcellent! PinmemberDominik Reichl2 Jul '03 - 8:55 
GeneralUseful tool PinmemberDavid Spain6 Aug '02 - 4:12 
GeneralRe: Useful tool PinmemberXSimon13 Aug '02 - 15:16 
GeneralPretty Good!! PinmemberWREY5 Aug '02 - 9:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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 | Mobile
Web02 | 2.6.130523.1 | Last Updated 1 Aug 2002
Article Copyright 2002 by Simon.W
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid