Article Preview
Buy Now
| Print: | |
| PDF: |
Beginner's Corner
Hierarchical Listboxes (Part 1)
Working with hierarchical listboxes
Issue: 6.1 (November/December 2007)
Author: Marc Zeedar
editor-at-rbdeveloper.com
Article Description: No description available.
Article Length (in bytes): 16,255
Starting Page Number: 32
RBD Number: 6113
Resource File(s):
6113.zip Updated: Thursday, November 15, 2007 at 10:34 AM
Related Link(s): None
Known Limitations: None
Excerpt of article text...
Recently a subscriber wrote me with a question about working with hierarchical listboxes. This is an important and complicated subject that I decided would make an excellent topic for Beginner's Corner.
In a normal Listbox, the list holds the data. In a hierarchical Listbox, some of the lines are hidden (collapsed), so the Listbox can't store that information. You have to write code that is executed when the user clicks the disclosure triangle and exposes the contents of the folder. Your code needs to get that hierarchical data from somewhere and insert rows of data into the Listbox.
So the real question is: where do you store this data? There are basically two approaches.
One: use an external data structure (an array, a dictionary, a class, an array of classes, whatever). The disadvantage with this approach is that you are duplicating the listbox functionality in another (invisible) structure and you have to handle data rearrangement and deletion, insertion, etc.
Two: the second approach is to hide the additional data (the stuff inside folders) inside the listbox itself. You can do this by using the row's CellTag property to store data inside it. The problem with this approach is that it really is only good for limited amounts of data. You can use it to store a refererence to some external data (i.e. a unique ID that is matched to an external dictionary object), but then we are getting more complicated again.
...End of Excerpt. Please purchase the magazine to read the full article.
Article copyrighted by REALbasic Developer magazine. All rights reserved.
|








