Example 4: changing the size and location of controls
The following DataWindow object shows city and state columns
enclosed in a rectangle and underlined. The columns change location
if the current row contains data for a customer from the state of
New York. The rectangle and the line change both location and size.

This example shows how to move the rectangle and line. The
process for columns is similar.
In the Design view, the rectangle and line display in one
location, with a single set of dimensions. The expressions you specify
are used only in Preview view and at runtime and all have the following
syntax:
|
1 |
If ( state='NY', <span>true value, false value </span>) |
The false value is the same as the value
in Design view. All of the values used in this example are in PowerBuilder
Units (PBUs), the default unit of measure used for the DataWindow object.
To change properties of the rectangle and the line for rows
with the state column equal to New York:
-
Select the rectangle, display
the Position page in the Properties view, and specify expressions
for the following properties:Property
Expression
X
if (state = 'NY',
2890, 1865)Width
if (state = 'NY',
500, 1000)Height
if (state = 'NY',
160, 120) -
Select the line, display the Position page in the
Properties view, and specify expressions for the following properties:Property
Expression
X1
if (state = 'NY',
2890, 1865)Y1
if (state = 'NY',
168, 132)X2
if (state = 'NY',
3400, 2865)Y2
if (state = 'NY',
168, 132) -
On the General page for the line, specify this expression
for Pen Width:1if (state = 'NY', 10, 4)At runtime, the rectangle is taller and narrower, and the
line is shorter and has a wider pen width.