Configuration
The combo box drop-down list can be configured in three different ways:
- Via Engineering
- Via an array from the PLC
- Array of a structure representing the structure of a list entry
The structure elements must be named identically to the attributes defined on the TwinCAT HMI side. Upper and lower case is taken into account. |
aComboboxEntries : ARRAY [1..5] OF ST_ComboboxEntry;
TYPE ST_ComboboxEntry:
STRUCT
id : INT;
text : STRING;
value : INT;
END_STRUCT
END_TYPE
- Array of a simple data type
aTexts : ARRAY [1..5] OF STRING;
aValues : ARRAY [1..5] OF INT;
The selected element of the drop-down list can be queried through various Attributes.
Definition via Engineering:
- Add a combo box to the interface.
- Change the drop-down list for the 'Src Data' attribute of the 'Data' category using the 'Combobox Src Data' dialog
- 1. Define the required number of entries and their sequence.
- 2. For each of the three entries, assign an ID, a text that is displayed in the drop-down list and the value behind this entry.
Definition via an array from the PLC:
- Add a combo box to the interface.
- Link the array to the 'Src Data' attribute of the 'Data' category
To display the information of the selected element in the drop-down list, you can perform the following steps:
- Add three text blocks.
- Link the first text block with the attribute 'TcHmiCombobox::SelectedIndex'.
- Link the second text block with the attribute 'TcHmiCombobox::SelectedText'.
- Link the third text block with the attribute 'TcHmiCombobox::SelectedValue'.
Sample project: Combobox