PDA

Click to See Complete Forum and Search --> : Get Flat File Data


kleptos
Feb 18th, 2003, 01:55 PM
I have a text file

1000|COL1|COL2|COL3|COL4|COL5|COL6|1
1001|COL1|COL2|COL3|COL4|COL5|COL6|0
1002|COL1|COL2|COL3|COL4|COL5|COL6|1

and i want to load ALL records and display COL1 in a ListBox (This i am able to do). Once i do that i want to be able to click on an element in the ListBox, go to that text file, get the other values (COL2, COL3, ETC) populate a few text boxes that all relate to that record (1000) in the textfile (Here is where i am lost). I also want to be able to update just that row (1000) with new data from the text boxes. For deleteing a row, i want to change the last character from a 1 (Active) to a 0 (Inactive).

Any help would be appreciated.

PT Exorcist
Feb 18th, 2003, 02:02 PM
put an stringtable that is filled up with arrays with each one of the values (the columns)..then just access the string table by the name(1000, 1001 etc..)

kleptos
Feb 18th, 2003, 02:24 PM
How would i save the file? Save the whole string table back to the file? Or is there another way?

CornedBee
Feb 19th, 2003, 04:59 AM
Is COL1 unique?

I'll assume it's not. In that case you need a struct that stores all columns and a bool active flag. Then you add a hashtable wich matches the ID to those structs. Then you add the ID as user data to the rows of the list box. When the user clicks an entry you get the ID, look up the corresponding struct and write its values into the edits.

For writing out you get the keys from the hashtable, sort them and loop through them, writing each entry to a new line in the file.

kleptos
Feb 19th, 2003, 08:51 AM
No, COL1 isn't unique, the first field 1000 is going to be the unique item per row.

Thanks for the help, i will try that as soon as i get a chance.