CheckedListBox
CheckedListBox
A CheckedListBox is a control that displays a list of items, each with its own checkbox.
This control is ideal for grouping multiple related states in a single component. For example, it can be used to manage a machine’s optional features (“Option 1 Active,” “Option 2 Active,” “Option 3 Active”).
Basic Configuration and Functionality
Configuring a CheckedListBox involves a two-step process:
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 to appear in the list (e.g., “Item 1,” “Item 2,” “Item 3”).
2. Bind Tags (Properties Panel)
- After adding items in the Advanced panel, return to the Properties panel.
- You will see the Value section automatically updated with the items you added.
- Each item now has its own tag slot (e.g., Item 1 (Tag)), allowing you to bind it to a separate BOOL tag.
This setup ensures that each item’s checked (True) or unchecked (False) status is two-way bound to its respective BOOL tag.
Properties Panel – Key Properties
Value
- Tag
- Purpose: Two-way binding between an item’s checkbox and a Boolean tag.
- Read: If Tag_A is True, “Item 1” is automatically checked.
- Write: If the operator checks “Item 1,” Tag_A becomes True.
- Index
- Purpose: Not related to the checked status. It binds the currently selected row’s index to a tag.
- Use: Tracks which item the operator has selected.
Events
- IndexChanged
- Purpose: More specific than the Click event. Triggered when the selection moves to a different item.
- Use: Display details about the selected item on another panel or run a script, even if the checkbox is not checked yet.
Advanced Panel – Key Properties
Items (Collection)
- Defines the list items.
CheckOnClick
- True (default): A single click both selects the item and toggles the checkbox.
- False: The first click selects the item, the second click toggles the checkbox.
SelectionMode
- One (default): Only one item can be selected at a time (multiple items can still be checked).
- None: Items cannot be selected, only checked.
Sorted
- If True, the items are automatically sorted alphabetically.
MultiColumn / ColumnWidth / HorizontalScrollbar
- For long lists, enable MultiColumn to spread the list across multiple columns.
General Usage Examples
Example 1: Multi-Option Panel (Basic Use)
Used to turn on/off three options of a machine (Heating, Vacuum, Mixer).
- Go to Advanced -> Items (Collection) and add: “Heating,” “Vacuum,” “Mixer.”
- Go to Properties -> Value, panel updates automatically.
- Bind the following tags:
- Heating (Tag) → Machine_Heating_Active (BOOL)
- Vacuum (Tag) → Machine_Vacuum_Active (BOOL)
- Mixer (Tag) → Machine_Mixer_Active (BOOL)
Result: Each option is fully synchronized with its Boolean tag. Checking “Vacuum” sets Machine_Vacuum_Active to True.
Example 2: Display Details of Selected Item (Using Index)
Show the function of the selected item in a Label control:
- Bind CheckedListBox → Properties → Value → Index to a tag called Selected_Index.
- Add a Label to the screen.
- Go to the Label’s Properties → Text and use + New (Condition):
- Condition 1: Selected_Index = 0 → Value: “This option enables heating on the machine.”
- Condition 2: Selected_Index = 1 → Value: “This option activates the vacuum pump.”
- Condition 3: Selected_Index = 2 → Value: “This option activates the mixer motor.”
Result: When the operator navigates the list with arrow keys or mouse, the Label text updates immediately according to the selected item.
