LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I dynamically "create" controls (or indicators)?

Let me explain my case:

- I have an array of data that represents a SINGLE record of a database table (columns contain: data label, data, data type; rows contain: the fields).
- I have to create as many indicators as fields are on the query (notice that there are different type of data, so it's necessary that the indicator should be of the same type, but that's another problem).
- As the number of fields vary on the query, I have to create the same number of indicators.

How can I do that? (Hiding the controls can be a solution, but it's limited to a max. number of fields)


It's clear we are talking about a common loop. But which is the function/control/whatever that can be used to dynamically create
the indicator/control?

Thanks in advance.
Mauricio Vidal
VIDAL & ASTUDILLO Ltda.
http://www.vidalastudillo.com
0 Kudos
Message 1 of 19
(12,853 Views)
There is currently no way to programmatically create controls. If the data is in an array why not just change the size of the array to display as many elements as you need, or am I mssing something?
Message 2 of 19
(12,853 Views)
Thank you for your answer Brian!
The array contains the data, but the idea behind is that every element can be modified according to its type (i.e. a date with a calendar). What I need is to create programmatically (or dynamically?) the controls as required.
But if you say there is not way to do it, I'll have to hide the unnecessary controls and limit the number of fields to be managed.
Thank you again!
Mauricio Vidal
VIDAL & ASTUDILLO Ltda.
http://www.vidalastudillo.com
0 Kudos
Message 3 of 19
(12,853 Views)
Hi jmva,

If you just want to display the info, then a picture control could be used, BUT, you are going to have to do all of the coding yourself, starting with basic geometric shapes and built-in routines for formatting text. Even if you have to go the next step and edit what is displayed, you could detect mouse clicks on the picture, do some math and map them to a cell of interest. Once you know which cell to edit you can pop-up an edit screen that uses normal controls.

I did not say this would be easy did I?

If you can put an upper limit on the number of indicators, you could just go with the hide/display route.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 4 of 19
(12,858 Views)
Great idea Ben,
to simplify the drawing I further suggest to create one hidden control for each type of data expected. You write data to its type control, get the picture of the control and append it to the pict control. When the users clicks on the area of a specific control on the pict, make visible the associated hidden control for user input.


LabVIEW, C'est LabVIEW

0 Kudos
Message 5 of 19
(12,860 Views)
This VI is a beginning for displaying data...
To add user editing would require to track the mouse hovering on the pict, assign current data to the associated control, make this control visible for edition. Further, the control currently under edition can be placed on top of its actual position on the pict so the user won't notice that the control swaps from a display on a pict to an actual control. Anyone want to implement this?


LabVIEW, C'est LabVIEW

Message 6 of 19
(12,872 Views)
Jean-Pierre,

I like your sample VI.
I have been inspired.

This reply is rated 5 stars *****

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 9 of 19
(12,872 Views)
There actually is a crude way to create new control instances. You must use
a .vit that contains a single control and then use vi server to create the
needed instances making each one appear as a transparent child window on the
parent vi. I have done this and it can be made to work, it is just a pain
in the ass.

"jmva" wrote in message
news:506500000008000000A33B0000-1012609683000@exchange.ni.com...
> Let me explain my case:
>
> - I have an array of data that represents a SINGLE record of a
> database table (columns contain: data label, data, data type; rows
> contain: the fields).
> - I have to create as many indicators as fields are on the query
> (notice that there are different type of data, so it's necessary that
> the indicator should be o
f the same type, but that's another problem).
> - As the number of fields vary on the query, I have to create the same
> number of indicators.
>
> How can I do that? (Hiding the controls can be a solution, but it's
> limited to a max. number of fields)
>
>
> It's clear we are talking about a common loop. But which is the
> function/control/whatever that can be used to dynamically create the
> indicator/control?
>
> Thanks in advance.
Message 7 of 19
(12,870 Views)
Dear Sirs:

Thank you for your answers. I noticed this topic is interesting for many people, so I would like to rephrase the answers - with your permit - in order to put it clear:

Objective: To create programmatically controls for a SINGLE record of a (database) table, containing three inputs: data label, data type and the data.

Routes proposed
First one: "If we want unlimited size of fields"
Again we have two approaches:
A. We can use Mr Ben and Mr Jean-Pierre's approach (whose VI is superb!) of having the controls programmatically inserted inside a picture control. At this point we can display the data nicely, but if we want to allow edition (most of the cases), we better continue Mr Jean-Pierre's directions. Unfortunately that requires high knowledge of the graphical interactions (even more if we want to make it generic and customizable). If anyone would like to share this solution, more than one (including myself) would be deeply grateful.

B. We can use Mr Sachsm approach for creating panels based on server. Unfortunately my LabView version doesn't support Polymorphic creation of VIs, so I wasn't able to test it.
However, the following route, number B, proposes the use of it in a different way.

Second one "Limiting the size of fields to show/edit".
We can place in our VI a maximum number of controls (of every type) for every single field. Here, in my opinion, we have two options to show the only type of control desired:

A. Hiding the non-required controls.
B. We can place a sub Vi which gets the three parameters (data, type, label) and returns the appropriate control. But here's the restriction for it: Can we do it with Polymorphic VIs? Let me explain: Can we take a .vit which contains vis for every type of control and place it in our original VI as many times as number of fields we want max.?

If the last is possible, it would be a pretty easy solution for this route. What I found attractive is that we can format the appearance of the controls modifying just the subVi of the vit.

Again, thank you for your time and help! Hope this helps many of us.

Best regards,

JAVIER MAURICIO
Mauricio Vidal
VIDAL & ASTUDILLO Ltda.
http://www.vidalastudillo.com
0 Kudos
Message 8 of 19
(12,731 Views)
Another solution would be to use a multicolumb list box. Using this approch
would allow you to detect what cell is active or double clicked. Based on
this you could pop up with some type of dialog to allow data entry (e.i.
Calender) or allow the user to enter text into the cell and then verify the
validity of the entered data.

Just a thought

Denis

"jmva" wrote in message
news:506500000008000000A33B0000-1012609683000@exchange.ni.com...
> Let me explain my case:
>
> - I have an array of data that represents a SINGLE record of a
> database table (columns contain: data label, data, data type; rows
> contain: the fields).
> - I have to create as many indicators as fields are on the query
> (notice that there are different type of data, so it's
necessary that
> the indicator should be of the same type, but that's another problem).
> - As the number of fields vary on the query, I have to create the same
> number of indicators.
>
> How can I do that? (Hiding the controls can be a solution, but it's
> limited to a max. number of fields)
>
>
> It's clear we are talking about a common loop. But which is the
> function/control/whatever that can be used to dynamically create the
> indicator/control?
>
> Thanks in advance.
Message 10 of 19
(12,886 Views)