Modifying a DataWindow object

At runtime, you can modify the appearance and behavior of a DataWindow object in a DataWindowControl by doing one of the following:

Changing property values

You can use the Modify or SetProperty methods to set property values. This lets you change settings that you ordinarily specify during development in the DataWindow painter.

Before changing a property, you might want to get the current value and save it in a variable, so you can restore the original value later. To obtain information about the current properties of a DataWindow object or a control in a DataWindow object, use the Describe or GetProperty method.

Some properties are available using GraphicObject classes. For example, you can use the GraphicObjectButton’s Text property to get or set the text on a button control in a DataWindow object.

Using expressions in property values

With some DataWindow properties, you can assign a value through an expression that the DataWindow evaluates at runtime, instead of having to assign a value directly. For example, the following statement displays a salary in red if it is less than $12,000, and in black otherwise:

dw1.Modify("salary.Color = '0 ~t if(salary <12000,255,0)' ")

For more information

The syntax is different for expressions in code versus expressions specified in the DataWindow painter. For the correct syntax and information about which properties can be assigned expressions, see Chapter 6, “Accessing DataWindow Object Properties in Code.”

Adding and deleting controls within the DataWindow object

You can also use the Modify method to:

Tool for easier coding of DataWindow syntax

From the Tool page in the New dialog box in DataWindow Designer, you can launch DWSyntax, a tool that makes it easy to build the correct syntax for Describe, Modify, and DataWindowSyntaxFromSql statements. You click buttons to specify which properties of a DataWindow you want to use, and DWSyntax automatically builds the appropriate syntax, which you can copy and paste into your application code.