Creating a Listbox Control
- 已更新2026-05-29
- 閱讀時間為 2 分鐘
Use a listbox control in LabVIEW to display selectable items on the front panel. Use a Case Structure on the block diagram to create code that handles selections in the listbox.
To create a listbox interactively, complete the following steps.
- Add a listbox control to the front panel window from .
- Add a listbox item: use the Labeling tool to enter an item name in the listbox and press the Enter key.
- Repeat step 2 for each item you want to enter in the listbox.
- Optional:
Set the number of
items a user can select in the listbox.
By default, users can select one item in a listbox control.
-
Create a
Case Structure on the block diagram to handle the selected
item with conditional code for each item.
How a listbox control behaves on the block diagram depends on the selection mode for the listbox.
Selection Mode Block Diagram Behavior 0 or 1 Item or 1 Item Listbox control appears as a 32-bit signed integer. The data value for a single-selection listbox is a number that represents the currently selected option. The first item in the list has a value of zero. If no item is selected, the value is –1.
0 or More Items or 1 or More Items Listbox control appears as an array of 32-bit signed integers. The value(s) in the array represent the currently selected item(s). If no item is selected, the value is an empty array.
To change the data type between scalar and array data, right-click the listbox control on the front panel and select .
You can also use the ListBox properties to add items to a listbox and to configure a listbox programmatically.