05-12-2011 04:00 AM
Hello,
I am new in LV. I want to know how I can create and destroy elements while my app is running. Eg. dynamiccally arrange a set of controls.
05-12-2011 04:06 AM
When you say destroy, do you mean remove from the program entirely?
Or perhaps you mean hide from view so that the user does not see them? Or maybe rearrange them on screen so that they look different?
The property node for visible lets you show/hide controls and indicators, and the positions can also be controlled by property nodes. At a guess this is probably what you are trying to achieve.
Ian
05-12-2011 04:15 AM
I want dynamiccally create a tree of devices and according to a different situation which the program may find at its start a different number of objects should be created. Later on the number of objects and its position within the tree should be possible to alter. So I do not only need to control the visuability property of some controls. I want to add and remove objects completely.
05-12-2011 04:36 AM
You could look into scripting to programmatically create LabVIEW code. However, you said that you are new to this, so I would recommend getting the hang of the basics first before trying to master scripting.
Think carefully about what you are trying to achieve with the user interface, do you really need to fully remove objects? What is wrong with hiding them from view and replacing them with others?
05-12-2011 04:55 AM
There is nothing wrong but it is a more static approach. My software does not really know about the structure and number of objects it will find at start time (e.g.). So from the view of a text based programming language I first would create my relevant objects according to the conditions I find. Now I have the impression that in LabView it would be better to create a bunch of objects during designtime and hide all the ones I don't need. What if I detect I will definitly need more as the previous defined ones. If I now have approx.100 objects in the layout of LV, it maight be rather unclear. I also want to use one base object for every new instantiated object. Is that possible in that way?
05-12-2011 05:22 AM
@npci wrote:
I also want to use one base object for every new instantiated object. Is that possible in that way?
If I understand you correctly you could use typedefs.
For example you could create an array of typedefined clusters. Each cluster could be a combination of items (controls, indicators etc). If these are in an array you can dynamically add or remove them by changing the size of the array.
The typedef is your 'base' object and allows you to modify your 'base' without breaking other parts of your code later on.
It would be relatively straightforward to create/destroy the elements of the array (i.e. add or remove the combinations of controls/indicators). You could also choose to display individual items by indexing the array to pull out particular clusters. This would allow you to programmatically allocate space at runtime.
If the user interface is important, you'd need to excercise some care in how all these parts are displayed. If the user interface is not visible you can just store your objects in the array and access them as you wish.
If memory serves me, Ben has written several posts on things like this. Searching some of his posts could serve you well.
05-12-2011 08:18 AM
To recap, you want to dynamically create a tree of devices and create a UI which allows easy control of those devices. And you are a new LabVIEW user. I have done things like this. Things you should avoid: