Example 3: creating a row indicator

This example demonstrates the use of several functions: Bitmap, Case, CurrentRow, GetRow, and RGB.

What you want to do

Using the Employee table in the Enterprise Application Sample Database, you create a DataWindow object using the Emp_id, Emp_fname, Emp_lname, and Salary columns.

In the painter, you want to display a number of items such as the number of the current row, an arrow that is an indicator of the current row, and the salary for an employee with a background color that depends on what the salary is.

How to do it

In the workspace, add the following:

What you get

Here is what the design of the DataWindow object looks like:

The header band in the sample Data Window object displays the computed field Current Row ( ). The first line of the Detail band displays a right arrow and the columns emp _ i d, emp _ f name, emp _ l name, and salary. The next line displays If ( current Row ( ) = get row ( ) , " Current " , " Not current " ). The last line of the Detail band displays Bitmap ( If ( Current Row ( ) = Get Row ( ), " c : backslash s a m p l backslash e x backslash c o d e backslash i n d i c a t r dot b m p " , " " ) ).

Here is what the data looks like with the second row current.

Displayed across the top of the sample are the headers Current Row, Employee I D, First Name, Last Name, and Salary. Under Current Row is the number 2. Data is displayed for employee ID 103, with the Salary highlighted. Beneath the data is the text Not current. Next is a pair of arrows pointing to the row for employee 105, and the word Current appears under the row. The salary for this employee is also highlighted. Last is an entry for employee 129 with no highlighting on salary and the words Not current displayed below the row.

Notice that the number of the current row is 2; the first row and the third row are "Not current" (and therefore display no bitmap); and the second row, which is the current row, displays the arrow row indicator.

On your screen, the salary in the first row has a green background because it is more than $40,000; the salary in the second row has a gray background because it is more than $60,000; and the salary in the third row has a white background, which matches the background of the DataWindow object.