Example Code

How to use subpanels to display different subVI front panels within a single host VI

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Download All

Overview

This example shows how to load VIs into a subpanel control, and display them on the front panel of a host VI.

Description

This example shows how to load VIs into a subpanel control, and display them on the front panel of a host VI. 

In the block diagram, change the inputs inside both cases of the case structure to reflect the location of VIs on your PC.  Run the program and toggle between the front panels of the 2 VIs by toggling the "Change subVI" button.

 

 

Requirements

  • LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1.  Negative to the paths of first and second subVI in the path controls.
  2. Run the VI and the Sub Panel will display the front panel of subVI.
  3. Toggle the "Change subVI" button to toggle between the front panels of the two VIs.

 

Additional Information or References

VI Snippet

1.png

 

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
NPK
Member
Member
on

hai i am trying to load multiple sub vi on each call to a subpanel , the problem i am facing is once executed subvi in a subpanel is not executing on the second call. please give some suggestions.

iannicholson
Member
Member
on

Some things to watch out for when using this pattern in the real world:

In this example there is no restricition on the number of times the Insert VI function runs while the loop is executing, nor is there any delay in the loop. Thus the chosen panel will be inserted into the subpanel control as fast and as many times as your computer will allow. Remember to design your loop properly so this does not happen.

Also, another way to do this would be to open the VI references outside the while loop, and wire them through to the case structure. This way the loading is done only once when the main VI is run, and not repeatedly. Granted, if you need the VI reference to be chosen dynamically this method will not work.

Finally, I believe it is good practice to close your VI references after you are done with them. The example relies on LabVIEW to automatically close the references, but a good habit is to close your own references since ActiveX and .NET refnums are not handled automatically at all.