04-25-2012 09:44 AM
All,
I've been getting familiar with the DB Connectivity Toolkit and have successfully wrote queries against our SQL Server database and dumped it into an array which is below. I'd now like to try to get the Tree View to add these plant names but I can't seem to understand how it works.
Does anyone have a example like mine which they have successfully done this?
04-25-2012 11:21 AM
Hi,
If you are asking how to dump the array into a tree control you can use the property nodes for the tree. There are some good examples of this in the developer zone documents/shared code.
You have to decide how to manage the parent child relationships for our data, not knowing how the data looks there is not much to be specific about.
05-04-2012 03:07 PM
The data looks like this once queried out of the SQL Server:
Plant1
Plant2
Plant3
etc....
First I want to see if I can even attempt this since this is my first stab at a Tree View Control of any kind. Searching around the internet on a how-to on how to use the Labview Tree Control appears to be non-existiant. Got a link to the Developer Zone that talks about Tree Views or a good how-to?
05-07-2012
11:37 AM
- last edited on
07-23-2025
05:37 PM
by
Content Cleaner
Eric,
Here's a few links that you might find useful.
https://www.ni.com/docs/en-US/bundle/labview/page/creating-a-tree-control.html
All of these examples show some different uses of tree controls, hopefully this wil help you get a start and some more understanding on LabVIEW Tree Controls.
-Nick-
05-25-2012 03:16 PM
Here is what I have so far which is just putting in one level into my tree view control...pretty simple.
I am unsure why it rendered the TreeControl reference as Tree2 in the image, but this is not the case.
05-25-2012 03:53 PM - edited 05-25-2012 03:56 PM
OK guys, I give up. I'm hoping someone can nudge me in the right direction. How do I wire an array of values like this...
...to the Edit Tree Items.Add Item method (and have it's children underneath the Plant name)?
05-29-2012 10:14 AM
OK, I've gotten a little farther now. I've noticed if I only place a ware to the Left Cell String, everything comes in at the top level which I don't want. But I'm stuck on how to make everything but the plant names child products? Like this.....
Plant1
LineCode1
ProductCode1
LineCode2
ProductCode2
Plant2
LineCode1
ProductCode1
LineCode2
ProductCode1
etc....
05-29-2012 10:42 AM
Eric,
Here's a quick example that should help you get your data to look like this
The tricky part of writing this program is going to be programmatically determining when to create a new child/parent. You'll have to write some logic that looks at the elements in the array to determine if a tag has already been created for it.
As you can see I've used a for loop to programmatically add several elements under the same parent tag. Best of Luck!
The attached Code is provided As Is. It has not been tested or validated as a product, for use in a deployed application or system, or for use in hazardous environments. You assume all risks for use of the Code and use of the Code is subject to the Sample Code License Terms which can be found at: http://ni.com/samplecodelicense
-Nick-
05-29-2012 03:58 PM - edited 05-29-2012 04:04 PM
Hi Nick,
I've gotten a little closer but I can't figure out how to compare what's been entered on the Tree to what is in the database and then determine WHERE in the tree it belongs. I took a stab at it but I get a blank node when the For Loops first run. I don't even know if the Match Regular Expression function is the correct function to call here.
Any ideas?
05-30-2012 10:07 AM
I would recommend using a simple Equal? function. Since the tags are being generated using information directly from the array and both data types are strings, this is the proper function to use.
You will need to come up with a strategy for how to compare the data currently in the tree with the data in the array. Or you could evaluate your array, break it apart and programmatically add items to the tree. Either way, keep in mind that every item still has a tag associated with it.
It is not very efficient to compare each data element with each tag already in the tree. Since your array seems to be pre sorted you could compare array elements in specific columns to one another looking for a change. When you have determined a change you will know which portion of the array belongs under the "Argentina" country tag, for example.
Currently you are comparing information from the array with the tags in the tree, but no matter the results you are still adding a new child to the tree under the top level parent. To determine where in the tree the piece of data should fall you need to specify a parent tag.
I hope this information is helpful.
-Nick-