Simple List

How do I return the value selected in a list.

What am i doing wrong here

event.source.parent.getComponent(‘Label’).text = event.source.data.getSelectedValues()

If (as your example code suggests) you are wanting to display the currently selected list value in a label, you would bind the label’s text property to an expression which uses the list’s selectedIndex property to read the correct value from its data property:if({Root Container.List.selectedIndex}>-1, {Root Container.List.data}[{Root Container.List.selectedIndex}, 0], "")The if statement is to cope with nothing in the list being selected, otherwise you will get an out of bounds error.

If on the other hand you want to access the currently selected list value in a script, you would use a script like the following:list = event.source.parent.getComponent('List') if list.selectedIndex>-1: selectedValue = list.data.getValueAt(list.selectedIndex,0) else: selectedValue = "" print selectedValueFor more information on bindings look in the user manual at Scripting / Expressions / Syntax. For more information on accessing data in a script look at Scripting / Python / Python in Ignition / Working with Different Datatypes.