Setting and forgetting the default attributes of tree items.

SRP Tree Control items have many attributes whose default values will be adequate in most cases. Furthermore, you can modify the attributes all tree items at once using the "All" index keyword. However, this alone is not sufficient if you aim to make the entire tree consistent in appearance or behavior.

For example, let's say you want the entire tree to use hyperlinks. You use "ItemHyperlink[All]" to ensure all existing items behave like hyperlinks. However, let's say you add new items to the tree later. By default, these new items are not hyperlinks. To make these new items hyperlinks, you have to either set the hyperlink field for each item in the array passed to the AddItems method, or you have to use "ItemHyperlink[All]" each time you add new items. But there is an easier way.

"Def" Properties

All items' attributes have defaults, and you can change those defaults using the default properties. Default properties have the "Def" prefix and mirror many of the Item properties. Setting a default property establishes the default value of an attribute for new items only. This is extremely useful for establishing a consistent look and feel from the beginning, rather than writing extra lines of code after each call to AddItems.

Going back to our example, we can use the DefHyperlink property to establish the default hyperlink attribute for all new items. And, if we do it before we load any items, then we never have to worry about it again. So, to make an entire tree use hyperlinks, just use the following line of code during initialization:

// Make all items behave like hyperlinks 
Set_Property(@Window:".OLE_TREE", "OLE.DefHyperlink", Yes$)

Not all item attributes can have a default property, such as data and image. See below for links to all available default properties.

See Also

DefAlignmentDefCheckBoxDefColorsDefDraggableDefDroppableDefEnabledDefExpandableDefExpandedDefFontDefHeightDefHyperlinkDefSelectableDefSortDefTypeDefVisible

  • No labels