Hierarchical ListBox from flat text file

While I was pesking about how internet is slow (of course, with a slow connexion and many things to do at once…), my brain was searching a solution to that problem (already asked here, but nothing helped me to find a solution I can build):

From a flat text file, how can I build - no - Fill a ListBox with AddFolder when needed.

Time for a simple explanation of my text file contents:
I list in a text file all published issues of a comic book (magazine). There are two kinds of issues:

a. Issue who holds one story, b. Issues who holds two or more stories.

The text file is - more or less - complete, but I can add easilly some more data to it.

Now the idea that comes to mind:

first, I was seeking a way to make a two consecutive treatments to the loaded text file:

a. Determine which line is a one story only b. Determine which line have two or more stories.

Then, I started to think that I am in a cul-de-sac (dead-end): I do not think at a way to store these computed data and then use them to fill the ListBox.

<time ellapsed while I was doing internet related stuff…>

Then: what if I import the text file data into a data base file ?

Very simple (to think at, right now, but the implemetation ?): I need two tables (Issues + Contents) where each Issue will have an entry in the Issues Table and Contents will have one to many entries for each Record in the Issues Table.

I have details to check, but… what do you think about that idea (design) ?

SQLite Table Design

Table Issues: the Record design
One Field for each atom of information I want to store about a magazine (issue #, Main Title, Release Date, Bar Code Label, …)
and a Field that will hold a reference (or a serie of references [how can I do that ?]) to the Contents Records affiliated to that issue (one Reference if there is only one story / One Reference for each stories belonging to that Issue).

Table Contents: the Record design
A Reference field that will make the link to the Issue owner,
All fiels needed to store the data I want, related to the Record story (Name, Start date, end date, Source, writer, “Painter”, source, …).

Once I have filled the SQLite Data Base file, I only have to open it and fill the ListBox with data from the Issue Table (AddRow) or Issues Table (AddFolder) and in ExpandRow, read the appropriate number of stories from the Contents Table.

As I wrote earlier, this is the general idea, the code have to be added later.

Correct if your listbox will only ever be one level deep.

[quote=205457:@Emile Schwarz]While I was pesking about how internet is slow (of course, with a slow connexion and many things to do at once…), my brain was searching a solution to that problem (already asked here, but nothing helped me to find a solution I can build):

From a flat text file, how can I build - no - Fill a ListBox with AddFolder when needed.

Time for a simple explanation of my text file contents:
I list in a text file all published issues of a comic book (magazine). There are two kinds of issues:

a. Issue who holds one story, b. Issues who holds two or more stories.

The text file is - more or less - complete, but I can add easilly some more data to it.

Now the idea that comes to mind:

first, I was seeking a way to make a two consecutive treatments to the loaded text file:

a. Determine which line is a one story only b. Determine which line have two or more stories.

Then, I started to think that I am in a cul-de-sac (dead-end): I do not think at a way to store these computed data and then use them to fill the ListBox.

<time ellapsed while I was doing internet related stuff…>

Then: what if I import the text file data into a data base file ?

Very simple (to think at, right now, but the implemetation ?): I need two tables (Issues + Contents) where each Issue will have an entry in the Issues Table and Contents will have one to many entries for each Record in the Issues Table.

I have details to check, but… what do you think about that idea (design) ?

SQLite Table Design
Table Issues: the Record design
One Field for each atom of information I want to store about a magazine (issue #, Main Title, Release Date, Bar Code Label, …)
and a Field that will hold a reference (or a serie of references [how can I do that ?]) to the Contents Records affiliated to that issue (one Reference if there is only one story / One Reference for each stories belonging to that Issue).

Table Contents: the Record design
A Reference field that will make the link to the Issue owner,
All fiels needed to store the data I want, related to the Record story (Name, Start date, end date, Source, writer, “Painter”, source, …).

Once I have filled the SQLite Data Base file, I only have to open it and fill the ListBox with data from the Issue Table (AddRow) or Issues Table (AddFolder) and in ExpandRow, read the appropriate number of stories from the Contents Table.

As I wrote earlier, this is the general idea, the code have to be added later.[/quote]
I wrote a class that does the text input completely.

Check it out here: www.simcarsoftware.com

Jeff, Simon: thank you.

I do not started to code (no time available to do that yet). Care to expand a bit why ?
You mean that I will need as many “nested” Tables as needed levels ?

BTW: I only need one level deep in the ListBox (the “master Row” that can be expanded / filled by two or more standard entries).

Simon:
I will try to get an eye on your Class (first download it, then…).

A different kind of relation.

Multi-nesting can be done with a single table.
In the table you have

MY_REF, MYNAME, PARENT_REF, VALUE1,VALUE2,VALUE3

In your first pass, you add a folder for every item that has no parent.

Select  * from MYTABLE where MY_REF not in (select PARENT_REF from MYTABLE);

Then when someone opens a folder, you get all the children using the reference:

Select  * from MYTABLE where PARENT_REF  = MY_REF ;

This approach works in theory for any level of nesting.

Thanks Jeff.