value = treectrl.expanded(item, parent);
treectrl.expanded(item, parent) = value;
The property returns true if the item is expanded (its children are visible) and false if it is collapsed. When setting the property the value true will expand the item's children and false will collapse them.
// Test ensureVisible, parent and get/set expanded
TreeCtrl.ensureVisible("End leaf");
index = TreeCtrl.parent("End leaf");
if (!TreeCtrl.expanded(index))
Env.LogError("Ensure visible did not expand the parent");
TreeCtrl.expanded(index) = false; // collapse parent back into place
TreeCtrl.expanded("Node 1") = false; // and the grandparent node