Taking advantage of conditional automation.

Conditions are an excellent way to define the behavior of the SRP Tree Control. Instead of writing your own code to specify when something should occur, you just send the condition logic to the SRP Tree Control to handle it for you. The following properties use conditions:

NameDescription
CheckBoxConditionsUses conditions to determine when a check box should appear to the left or right of an item, if at all
DragConditionUses conditions to determine if the user is allowed to drag and item
DropConditionUses conditions to determine if the user is allowed to drop other tree items onto the target item
FilterUses conditions to determine if an item is visible
ImageConditionsUses conditions to determine which global image to use for an item
ImageEffectsUses conditions to determine which effect to apply to an item's image at any given time

You will pass condition strings to these properties to instruct the SRP Tree Control on how to proceed with certain tasks. Properties using the plural form accept multiple sequential conditions, like a case statement. Properties using the singular form accept a single condition that is used to make a simple decision. Refer to the individual properties for details.

A condition string is a specially formatted string that the control will parse and execute. The format is that of a Boolean expression, that is, a mathematical expression that ultimately evaluates to true or false. Here are some sample expressions:

"Selected" 
"Selected AND Not(HasChildren)" 
"HasOnlyLeaves AND (Selected OR Checked)" 
"Level LT 1" 
"Class EQ 'Group'"

Notice that the condition strings take on the BASIC+ language syntax, although you may also use operators from other familiar languages, such as C++. Here are the same sample conditions using C++ operatores:

"Selected" 
"Selected && !HasChildren" 
"HasOnlyLeaves && (Selected || Checked)" 
"Level < 1" 
"Class == 'Group'"

The following operators are available to you when writing conditions:

NameOperator(s)Example
Logical OROR, ||"Selected OR Checked"
Logical ANDAND, &&"Hot AND Selected"
EqualsEQ, =, =="Class = 'Group'"
Not EqualsNE, #, !=, <>"Class # 'Group'"
Greater ThanGT, >"Level > 1"
Greater Than or Equal ToGE, >="Level >= 2"
Less ThanLT, <"Level < 2"
Less Than or Equal ToLE, <="Level <= 1"
NotNot(expr), !expr"Not(HasOnlyLeaves)"

The SRP Tree Control allows the use of a limited set of keywords in your conditions. Keywords identify a particular state of a tree item. You may use the following keywords in your condition statement:

KeywordTypeDescription
CheckedBooleanThe item's checked state
HotBooleanThe item's hot state. An item is hot when the mouse hovers over it
EnabledBooleanThe item's enabled state
SelectedBooleanThe item's selected state
ExpandedBooleanThe item's expanded state
HasChildrenBooleanTrue if the item has children
HasOnlyBranchesBooleanTrue if at least on child items has children
HasOnlyLeavesBooleanTrue if no children have children
LevelIntegerThe item's indent level. Level 1 items are at the root level. Level 2 items have at least one parent, and so on.
ClassStringThe item's class name.
ParentClassStringThe item's parent's class name.
KeyStringThe item's unique key ID.
ParentKeyStringThe item's parent's unique key ID.
TextStringThe item's text.

In addition to the above pre-defined keywords, conditions can also reference any user defined field as defined in the ItemFields or ItemField properties.

Using equality operators with Boolean keywords is optional, so "Selected" and "Selected EQ 1" are equivalent. The integer and string keywords require the use of the equality or comparison operators. So use "Level > 1" or "Class = 'Group'" instead of just "Level" or "Class".

If your conditions do not seem to working, double check your syntax. The condition is case insensitive, but you must spell the keywords correctly. Make sure your string values are incased in quotes and that your integer values are not. Also make sure that you are not using unary operators on integer or string keywords.

To make a condition that evaluates to true in all cases, just set it to "1".

See Also

CheckBoxConditionsDragConditionDropConditionImageConditionsImageEffects

  • No labels