Configuration

The combo box drop-down list can be configured in three different ways:

Configuration 1:

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
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:

  1. Add a combo box to the interface.
  2. Change the drop-down list for the 'Src Data' attribute of the 'Data' category using the 'Combobox Src Data' dialog
  3. 1. Define the required number of entries and their sequence.
  4. 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:

  1. Add a combo box to the interface.
  2. 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:

  1. Add three text blocks.
  2. Link the first text block with the attribute 'TcHmiCombobox::SelectedIndex'.
  3. Link the second text block with the attribute 'TcHmiCombobox::SelectedText'.
  4. Link the third text block with the attribute 'TcHmiCombobox::SelectedValue'.

Sample project: Combobox