Modifying properties at runtime

In some cases, however, you might want some properties of controls in DataWindow objects to be driven by the data, which is not known when you are defining the DataWindow object in the painter. For these situations you can define property conditional expressions, which are expressions that are evaluated at runtime.

You can use these expressions to conditionally and dynamically modify the appearance and behavior of your DataWindow object at runtime. The results of the expressions set the values of properties of controls in the DataWindow object.

In the following DataWindow object, the Salary Plus Benefits column has a Shadow box border highlighting each data value that is greater than $60,000:

The sample DataWindow object shows three columns of check boxes labeled Health Ins, Life Ins, and Day Care. The fourth column, Salary Plus Benefits, has a Shadow box border around every dollar value that is greater than $60,000.

To control the display of the border, you define a property conditional expression for the column’s Border property. When users run the DataWindow object, DataWindow Designer changes the border of individual data values based on the condition (value greater than $60,000).

A look at the expression

The expression you enter almost always begins with If. Then you specify three things: the condition, what happens if it is true, and what happens if it is false. Parentheses surround the three things and commas separate them:

If( expression, true, false )

The following expression is used in the example. Because the expression is for the Border property, the values for true and false indicate particular borders. The value 1 means Shadow box border and the value 0 means no border:

If(salary_plus_benefits > 60000, 1, 0)

When users run the DataWindow object, DataWindow .NET checks the value in the computed column called salary_plus_benefits to see if it is greater than 60,000. If it is (true), DataWindow .NET displays the value with the Shadow box border. If not (false), DataWindow .NET displays the value with no border.

About specifying properties

Usually you specify a number to indicate what you want for a particular property. For example, the following list shows all of the borders you can specify and the numbers you use. If you want the border property to be Shadow box, you specify 1 in the If statement, for either true or false.

In the Properties window, the list of choices for setting a property includes the values that correspond to choices in parentheses. This makes it easier to define an expression for a property; you do not need to look up the values. For example, if you want to specify the ResizeBorder in your expression, you use the number 3.

For details on the values of properties that can be set using expressions, see “Supplying property values”.

For complete information about what the valid values are for all properties associated with a DataWindow object, see the discussion of DataWindow object properties in the DataWindow Object Reference or online Help.

About modifying properties programmatically

You can also programmatically modify the properties of controls in a DataWindow object at runtime. For more information, see the Programmer’s Guide.