Saving Treeview nodes to file, and records

Please discuss general Delphi programming topics here.

Saving Treeview nodes to file, and records

Postby Proto » May 9th, 2009, 10:03 am

hey gang, hope everyone is well :P

I am developing an application management program (see screenshot below)

The problem I am having is to do with saving the settings or Treeview. I have googled and seen an example on saving in the xml format but my xml knowledge is nil,

The goal is to beable to save the treenode to a single file along with the images. however (the big problem) i have assigned records to each node using the (pointer to a record) in which contains unique information based on each node.

Code: Select all
   PAppItem   = ^TAppItem;
   TAppItem  = Record
     sFileName    :String;
     sFilePath    :String;
     sCategory    :TTreeNode;
     cmdShow      :Integer;

category nodes do not have this record assigned to it but application nodes do. Is it possible to save all this data?
Posts: 1
Joined: May 9th, 2009, 10:01 am

Re: Saving Treeview nodes to file, and records

Postby Kambiz » May 10th, 2009, 1:51 pm

XML is one of the most suitable formats to store hierarchical data. I do suggest to spend some times to study XML. It's very easy to learn.

Anyway, you can save your data in the format you which. Traverse TreeView nodes from root to leaves, and save data of each node that you visit. Remember, you have to assign a unique ID to each node and save ID of node and its parent besides your other data.

To load TreeView, for each node load its data, here you will have ID of node and its parent too. Use ID to locate a node with specified ID in the TreeView. Mostly the does not exists and you have to create it. Therefore you have to locate for its parent node using the parent ID to find where you have to insert the new node. This procedure is recursive.

If you couldn't figure out the code, I'll post a sample.
User avatar
Posts: 2424
Joined: March 7th, 2003, 7:10 pm

Re: Saving Treeview nodes to file, and records

Postby Johan Theunissen » May 15th, 2009, 4:16 pm


For excellent delphi open source code for handling XML and also documentation on XML you can download XML Partner from TurboPower, You will find it on
Johan Theunissen
Active Member
Active Member
Posts: 9
Joined: November 6th, 2008, 7:26 pm

Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 2 guests