ComponentOne True DataControl 8.0
Control Property Expressions

Promoting the idea of codeless application development, True DataControl provides a feature similar to “dynamic properties” in Microsoft Internet Explorer 5.0 dynamic HTML. You can make any property of any control dependent on certain variables, so that the property will always be kept in synch with variable values, without any manual coding.

For example, you might specify (in pseudocode, actual notation see below)

Example Title
Copy Code
Text1.Font.Bold = RequiredDate - ShippedDate < 10

True DataControl will maintain the font in the Text1 control so it will be bold if and only if the expression on the right is true. Whenever one of the two fields, RequiredDate or ShippedDate changes (due to repositioning to a different record, or data modification or any other reason), True DataControl will automatically update the font of Text1.

The expressions are held in the PropertyExpressions collection of True DataControl. This collection can be specified at design time in the Property Expressions property page, or by accessing the PropertyExpressions property in code at run time.

Each expression is associated with a property of a control belonging to the parent form of the TData control. This includes all controls (not only data-bound controls) and the form itself. At run time, True DataControl evaluates each expression and sets the corresponding control property to the resulting value whenever the value changes.

Control property expressions are evaluated when the TData control has been positioned on a record. If any variable within the expression changes, the entire expression is re-evaluated and the affected property receives the resulting value.

The PropertyExpression object, an item of the PropertyExpressions collection, has the following properties:

ControlName

The name of the control whose property is governed by the expression. It is the control’s Name property, with Index in parentheses, if this is an element of a control array. Examples: Text1, Form1, TextArray(2).

PropertyName

The name of the property governed by the expression, for example, BackColor. Nested properties such as Font.Bold are also supported.

ValueExpression

Specifies an expression that provides the value for the associated property at run time.

To facilitate assigning expressions to properties, the Property Expressions property page contains a tree view of all available controls and their properties. All controls belonging to the same form as the TData control, including the form itself, appear in the tree view. You can select a property in the tree view, type in an expression and press the New button. That will create a property expression.

Property expressions can also be set in code, as in the following example:

Example Title
Copy Code
TData1.ChangeInProgress = True

With TData1.PropertyExpressions.Add(0)

.ControlName = "Text1"

.PropertyName = " Font.Bold"

.ValueExpression = " RequiredDate - ShippedDate < 10"

End With

TData1.ChangeInProgress = False

As with all True DataControl collections, any change to property expressions in code outside the WillOpenData event, causes refresh of the TData control. If you do it outside WillOpenData, use the ChangeInProgress property to make the change at once, without intermediate refreshes. Without ChangeInProgress, the above example would cause refresh four times.

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback