Complete the following steps to create a listbox.
- Add a listbox control to the front panel window.
- 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.
- Create a Case structure to handle the selected item. A listbox with a selection mode set to 0 or 1 Item or to 1 Item appears on the block diagram as a 32-bit signed integer. You can right-click a tree control on the front panel and select Selection Mode»Data Type from the shortcut menu to change the data type. 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.
A listbox with a selection mode set to 0 or More Items or to 1 or More Items appears on the block diagram as an array of 32-bit signed integers, where the value(s) in the array represent the currently selected item(s). If no item is selected, the value is an empty array.
You also can use the ListBox properties to add items to a listbox and to configure a listbox programmatically.