ComboBox

ComboBox

A ComboBox is a compact drop-down control that allows an operator to select a single option from a predefined list.

Unlike a ListBox, a ComboBox occupies minimal space on the screen and only displays the full list when clicked. This makes it ideal for tasks such as mode selection, recipe selection, or choosing a parameter from a limited set.

Basic Configuration and Functionality

Configuring a ComboBox is similar to a CheckedListBox and involves two main steps:

1. Define Items (Advanced Panel)

  • Go to the control’s Advanced panel.
  • Under the Data category, find the Items property.
  • Open the collection and add the text items you want in the list (e.g., “Mode 1,” “Mode 2,” “Automatic”).

2. Bind Selection to a Tag (Properties Panel)

  • After adding items in the Advanced panel, return to the Properties panel.
  • Use the Value section to bind the operator’s selection to a SCADA tag.

Properties Panel – Key Properties

Value

  • Index
    • Purpose: Two-way binding of the selected item’s index to a tag.
    • Indexing: The first item = 0, second = 1, third = 2.
    • Use: Common in PLC programming where the PLC uses numeric values instead of text.

Events

  • Index Changed
    • Purpose: Triggered when the operator selects a different item from the list.
    • Use: Run a script immediately (e.g., “Load Recipe”) or change a panel’s visibility.

Text

  • Purpose: Two-way binding of the selected item’s text (e.g., “Automatic”) to a string tag.
  • Use: Ideal for directly writing the selected item’s name (e.g., a recipe name) to a string tag or using it in scripts.

Advanced Panel – Key Properties

DropDownStyle

  • Determines how the ComboBox behaves:
  • DropDown: Operator can select from the list or type a custom value.
  • DropDownList (default): Operator can only select from the list. Prevents invalid input.
  • Simple: List always open, text box displayed on top (rarely used).

Items

  • The list of options presented to the operator.

Sorted

  • If True, items are automatically sorted alphabetically.

General Usage Examples

Example 1: Machine Mode Selection (Index Binding – Most Common)

  1. Operator selects a machine mode (Manual, Automatic, Maintenance).
  2. Advanced → Items → Add: “Manual,” “Automatic,” “Maintenance.”
  3. Properties → Value → Index → Bind to a tag called Machine_Mod.

Result:

  • Selecting “Manual” → Machine_Mod = 0
  • Selecting “Automatic” → Machine_Mod = 1
  • Selecting “Maintenance” → Machine_Mod = 2
  • If PLC sets Machine_Mod = 1, the ComboBox automatically shows “Automatic.”

Example 2: Recipe Name Selection (Text Binding)

  1. Operator selects the recipe to load by name.
  2. Advanced → Items → Add: “Recipe_A,” “Recipe_B,” “Recipe_C.”
  3. Properties → Value → Text → Bind to a string tag Selected_Recipe_Name.
  4. Properties → Events → Index Changed → Bind a script called Recipe_Load.

Result: Selecting “Recipe_B” sets Selected_Recipe_Name = “Recipe_B” and triggers the Recipe_Load script.

Example 3: Read-Only Status Display

  1. Display the current machine mode from the PLC; the operator cannot change it.
  2. Set up Items and Index binding as in Example 1.
  3. Properties → Enable → Default = False (or bind to a condition).

Result: The ComboBox appears gray and read-only. If PLC sets Machine_Mod = 2, the ComboBox shows “Maintenance,” but the operator cannot change it.

Leave a Reply