Powerbuilder Data Window Programming Tips

zhaozj2021-02-17  70

PowerBuilder Data Window Programming Tips Ten Cai Weilong 01-6-25 05:40:23

The reason why PowerBuilder has achieved great achievements, DataWindow is a feature of powerful and flexible, and I have developed some techniques after I have developed with PowerBuilder, and summarize some techniques for use.

One. How to create a report, as follows

Quantity Running Total

5,000 5,000

2,500 7,500

3,000 10,500

12,000 22,500

For Running Total columns, we can use comparison columns: cumulativesum (Quantity for ALL) to achieve a function of gradually incorporating and summing.

two. The four steps confirmed by the data window data to the buffer are determined whether the data type is correct. Trigger the ITEMEMERROR event if it is incorrect. Determine whether the data is in line with the effectiveness rules. If the effectiveness rules are not met, the ITEMEMERROR event is also triggered. It is determined whether there is data being changed. Decision data will trigger the ITEMERROR event if the data and itemchange are repelled by ItemChanged events.

three. How to find the list of data types for DateTime in DataWindow

1. The following expression is used when the date condition to be found is a constant:

Ls_find = "DATETIME_COL

= DATETIME ('1/1/1999') "

2. The following expression is used when the date condition to be found is a variable:

Ls_find = "DATETIME_COL = DateTime ('" ls_date "") "

3. The following expression is used when the date condition to be found is a DateTime data type:

Ls_find = "DATETIME_COL = DateTime ('" string (ldt_datetime) ")"

four. Set three methods for setting up data window Boolean properties

PowerBuilder provides three ways to set up the Boolean properties of the data window, named, Dalse, 1/0, 'Yes' / 'NO'. E.g:

DW_1.Object.address.visible = 0 dw_1.object.address.visible = false dw_1.object.address.visible = 'no'

PowerBuilder saves attributes in the form of a string without considering the property value, long integer or character. To further understand, you can export a data window and view its original code, you can find that even the color attribute of the column is also expressed using a number with double quotes.

Fives. How to quickly delete multiple lines in DataWindow

In the development process, there may often be a multi-line delete operation, usually use a loop statement to operate:

For LL_ROWON = 1 to dw_1.rowcount () dw_1.deleterow (ll_rowon) Next

A fast deletion method is to move the row to be deleted from the main buffer to the delete buffer. For example, delete all lines in the buffer:

DW_1.Rowsmove (dw_1, 1, dw_1.rowcount, primary!, dw_1, 1, delete!)

But don't forget the filtering rows in different buffers.

six. How to use the Select DistINCT implementation to delete the repeated row in the DataWindow's SQL syntax first to sort the columns you want to display: "City A", then add the following filter strings: "City <> city [-1] or GetRow () = 1 "

Seven. How to display the line numbers in each group in the DataWindow in the group

When we displays the line number for each row of DataWindow, you can make a simple representation of the Gtrow (). But for grouping DataWindow, the line number of each group is displayed separately, and the expression should be used as getRow () -first (GETROW () for group 1) 1.

Eight. How to change the font color of the column, remind the user that this column has been modified

In the color attribute of the column, enter the following expression

IF (column_name <> column_name.original, RGB (255, 0, 0), RGB (0, 0, 0)).

In this condition, if this column has changed, the red font is displayed, otherwise the black font is displayed. This expression is mainly used to compare the value of the current column and the value of the value of the original column in the same value to the original column.

nine. Move rows in the data window, but not to do filter or delete operations

The ROWSDISCARD () function can do this, it performs removal work in the data window, but the row that is removed is not deleted or made for any modified saver.

ten. How to display the first line of the current data and the last line number of the current data in the Footer Band in multi-line displayed DataWindow

Let's take a look at the expression of two computed columns:

IF (GetRow () = first (GetRow () for page), 1, 0) // 1 for the first line of the current page

IF (GetRow () <> 1 and getRow () = last (getrow () for page), 1, 0) // 1 for the last line of the current page

As can be seen from the above, set the following calculation column expression in the Footer Band:

'ROWS' STRING (GetRow () for page) 'to' string (last (get () for page) 'Are Displayed'.

This function can be reached.

转载请注明原文地址:https://www.9cbs.com/read-31060.html

New Post(0)