Example 4: changing the size and location of controls

The following report 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.

The sample DataWindow object is titled Customers from New York. It has columns for customer I D, name and address. To their right are city and state columns that are a single line of underlined text highlighted with a dark rectangle. One customer in the sample is from New York. For that customer, the rectangle is shifted to the far right and changes to a narrower dark rectangle with two lines of text.

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:

If ( state='NY', true value, false value )

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 report.

To change properties of the rectangle and the line for rows with the state column equal to New York:

  1. 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)

  2. 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)

  3. On the General page for the line, specify this expression for Pen Width:

    if (state = 'NY', 10, 4)
    

    At runtime, the rectangle is taller and narrower, and the line is shorter and has a wider pen width.