Random Ramblings on LabVIEW Design

Community Browser
Labels
cancel
Showing results for 
Search instead for 
Did you mean: 

Tree Control - A Little Present

Active Participant

What-ho G-Programmers of the world!

If like me you find programming the tree control to be a pain in the bum you may be interested in this little bit of code.

With it you can take a database table and create a tree hierarchy

database.jpg

So the table above will create a tree that looks like this when you use the query SELECT * FROM experimentTree

tree1.jpg

Going back the other way we want to generate SQL INSERT statements (this is SQLite flavour) or a table of data to parse back.

INSERT.jpg

The code to generate this is included in the teststub. As a separate statement or as part of the main statement you should also empty the table.

DELETE

FROM

          "main"."experimentTree".

The front panel of the teststub looks like this

Front Panel.jpg

To get a tree from the database the block diagram looks like this.

GetTreeFromdB.jpg

To plant a tree in your database, the block diagram looks like this.

GetdBDataFromTree.jpg

For simplicity I have contrived the tags. For my purposes I will be linking the selection to an experiment, obviously your requirements may differ, in essence the experiment field will be a foreign key into another table.

It's in LabVIEW 2014, but I can down-version if required.

Perhaps this will help make tree-huggers of us all

Much Love

Steve

 photo 4be9e774-656d-44c1-9a8d-1db1a15cdd42_zps6445ae67.png
Comments
Member

Nice code , tree controls can be a pain to set up so this will be useful.

I like the term 'plant' the tree

Active Participant

It's the little things, it was my favorite bit too!

It's pretty robust (as a quick bit of experimental code) which bodes well for the future. I was dragging the tree nodes around and it was saving them really well.

 photo 4be9e774-656d-44c1-9a8d-1db1a15cdd42_zps6445ae67.png