Dynamically Registering for Events

LabVIEW 2018 Help

Edition Date: March 2018
Part Number: 371361R-01
View Product Info

DOWNLOAD (Windows Only)

LabVIEW 2016 Help
LabVIEW 2017 Help
LabVIEW 2018 Help
LabVIEW 2019 Help
LabVIEW 2020 Help

Dynamic event registration allows you to use VI Server references, such as Application, VI, or Control, to specify at run time the objects for which you want LabVIEW to generate events.

What to Use

Use the following block diagram objects to dynamically register events.

Register For Events While Loop Event Structure Unregister For Events

What to Do

Create the following block diagram to dynamically register the Mouse Enter and Mouse Leave events on a string control.

The following list describes important details about the previous diagram.

Obtain VI Server references to the objects for which you want LabVIEW to generate events. To obtain a control reference constant, like the string control constant from the previous illustration, use a Property Node to query the VI for its controls or right-click the control and select Create»Reference from the shortcut menu.
Use the Register For Events function to dynamically register for events. You can register for multiple events for a single reference by resizing this function and selecting another event. Click the down arrow on the event source input and select the event you want LabVIEW to generate for the reference, such as the Mouse Enter and Mouse Leave events shown in the previous illustration. After registration, LabVIEW queues events as they occur until an Event structure executes to handle the events.
Tip Tip  You can view the registered events in the Context Help window when you hover over the event registration refnum.
Right-click the event selector label to display the Edit Events dialog box. Use the dialog box to configure an Event structure to handle a dynamically registered event. The Event Sources section of the dialog box contains a Dynamic subheading that lists each dynamically registered event source. After you select the events you want the Event structure to handle, design the case to handle the event data.
Use the Unregister For Events function to stop event generation. When the Unregister For Events function executes, LabVIEW unregisters all events the event registration refnum specifies, destroys the event queue associated with the event registration refnum, and discards any events that remain in the queue.

Caveats and Recommendations for Dynamically Registering Events

  • Wire the event registration refnum input of the Register For Events function only when you want to modify an existing registration.
  • Wire each Event structure that handles dynamic events to a unique Register For Events function. Branching the event registration refnum wire of a Register For Events function allows multiple Event structures to pull events from one queue, resulting in a race condition that may cause unpredictable behavior.
  • Before you configure events for the Event structure to handle, review the caveats and recommendations for using events in LabVIEW.


Refer to the labview\examples\Dialog and User Interface\Events\Events.lvproj for examples of dynamically registering events.


Not Helpful