Question about Hierarchical ListBoxes


in my application I have an hierarchical listbox. I want that when I select an element of the listbox a, the app automatically selects all the “sub-elements” corresponding to the select one. Now, this is trivial when the element is expanded (as the row number will also include the sub-elements), however, how to do that when the element is not expanded (and I’d like to avoid to expand it)?

I hope my question is clear.


When the row is not expanded, the sub-rows literally do not exist, so there is nothing to select. What are you trying to achieve?

This is my scenario. I have a custom class with SQLiteDatabase as super. In a listbox I have the list of these custom objects where the sub-elements are the column of the sqlite database. I defined some actions to be performed on the selected columns. I just wanted that if the user select the custom object, all the corresponding columns were selected so that a given action could be performed for all the columns.


When the user expands a row, how do you populate the sub-rows?

with something like this:

Dim sql As String
sql = “SELECT * FROM “”” + Me.Name + “”";"
Dim data As RecordSet
data = Me.SQLSelect(sql)

and then I fill the sub-rows with the IdxField(i).Name

If the row is not expanded, you will have to detect that and run that same query to get the columns. It sounds like you might want to restructure your code to work off an array instead of working off the listbox directly. When the user executes some action, examine the listbox and either fill the array with the selected sub-rows, or if the row is not expanded, load the array from the database.

thanks Tim, good suggestion. I will investigate that.