Handling Selections in Custom Menus
- Updated2026-03-31
- 2 minute(s) read
After you customize a menu statically or programmatically, create code that defines the behavior for each item in the custom menu. Use the Event structure and the Menu Selection (User) event to do so.
In most situations, when you are creating block diagrams for a user interface, you are already using an Event structure. Event structures can define behavior to correspond with the elements of an interface that a user can interact with.
Use the Menu Selection (User) event within an Event structure to define the behavior that happens when your end user selects a custom menu item that you have added.
To handle custom menu items with the Menu Selection (User) event, complete the following steps.
-
Add the Menu Selection (User) event case to the
Event structure.
- Right-click the border of the Event structure and select Add Event Case....
- In Event Sources, select <This VI>.
- In Events, select Menu Selection (User) and click OK.
-
Right-click the data field that appears in the event data node and select .
ItemTag corresponds to the tag of a menu item. The Insert Menu Items function defines the tag of a menu item. If you provided only a name to Insert Menu Items, then the tag is the same as the name.
- Add a Case structure to the Menu Selection (User) event case of the Event structure.
- Wire ItemTag to the case selector of the Case structure.
-
Add individual cases for each custom menu item you created.
-
For the case selector label, enter the tag of the custom menu item.
LabVIEW does not autopopulate the tags of custom menu items. Ensure the name of the case matches the tag of the menu item.
- Add code to the case subdiagram to define the behavior when a user selects the custom menu item.
-
For the case selector label, enter the tag of the custom menu item.
Related Information
- Case Structures: Executing a Section of Code Based on Input Values
Use the LabVIEW Case structure to run one subdiagram based on a selector input value. The behavior of the Case structure is similar to switch statements or if...then...else statements in text-based languages.
- Event-Driven Programming