How to use the DBTreeview Demo

Around 2001, using Delphi 6, I developed the TGtroDBTreeview component for a Personal Information Manager. It was a fairly complex database application that used Paradox tables and the Borland Database Engine (BDE).

As you can see from the listing of the demo program, the demo itself is extremely simple but a level of complexity is introduced by the fact that the component needs to be connected to a database for its execution. Originally, it was connected to a Paradox database through the BDE but, for this demo, I have connected to an Access database through ADO.

What I have done

On a form, I dropped

Using Access 2010, I have created a MS Access database called DBTreeviewDemo.mdb containing one table called DBDemoTable containing 5 fields:

Here, the Memo field is used for the display of the data pertaining to each node of the treeview but other fields could be used.

Each record of the table is in a one-to-one correspondance with one node of the treeview. The RefNo and Parent fields are used internally to locate the nodes in the treeview whereas the Caption field contains the caption of the nodes displayed in the treeview.

The IsFolder field is not necessary for this demo but it was required for the original application. On creation of a node with the DBNavigator (it is controlled by the code of the component) the program offers a choice for the type of the node to be created: folder (it can contain other folders or sheets) or sheet (a sheet cannot have a child). Since the original application was in french, the dialog that appears when creating a new node is in french (Noeud répertoire = folder node).

Since I did not want the table to be empty, I have inserted some geographical data into it.

Important!

The dbtreeview demo.zip file that you have downloaded and unzipped contains the code of the demo including an executable called DBTreeviewDemo.exe that can be executed and used as is.The file also contains the code for this program as well as the database itself.

Before loading the code in the Delphi IDE, you need to install the component. Simply compile the gtroDBLib7 packages contained in the gtrodblib.zip and install it. Three components including the TgtroDBTreeview component will be installed in the GTRO pane of the component palette. If you don't, Delphi will complain.

You are now ready to compile and execute the demo program.

With the navigator, you can add and remove nodes (the button which are available dictate what you can do). The nodes can be dragged and dropped too.

Good luck! Have fun!