Pb (PowerBuilder) The reason for the great achievements is that there are DataWindow objects, DataWindow is a powerful and flexible features, I used PowerBuilder development after a period of time, summed up some skills, For the vast number of PB developers to use for reference.
A How to create a report, as the following form
Quantity Running Total
5,000 5,000
2,500 7,500
3,000 10,500
12,000 22,500
For the running Total column, we can use computed columns: Cumulativesum (Quantity for all) to achieve progressively incremental summation.
Two The four steps that are confirmed before the data buffer is sent to the data window to determine whether the data type is correct. If not correct, triggers the Itemerror event. Determine if the data conforms to the validation rules. If the validation rule is not met, the Itemerror event is also triggered. Determine if any data has been altered. Determines whether the data passes through the ItemChanged event, and if the data and itemchanged repel, the Itemerror event is triggered.
Three How to find in DataWindow with a data type of datetime column criteria
1. Use the following expression when you are looking for a date condition that is a constant:
Ls_find = "Datetime_col
= DateTime (' 1/1/1999 ')
2. Use the following expression when the date condition you want to find is a variable:
Ls_find = "Datetime_col = DateTime (' + ls_date + ')"
3. Use the following expression when you are looking for a date condition that is a datetime data type:
Ls_find = "Datetime_col = DateTime ('" + String (ldt_datetime) + "")
Four Three ways to set a Boolean property on a data window
PowerBuilder provides three methods for setting the Boolean properties of the Data window, namely True/false, 1/0, ' Yes '/' No '. For example:
dw_1.Object.address.Visible = 0 Dw_1.Object.address.Visible = False dw_1.Object.address.Visible = ' No '
PowerBuilder saves the property as a string on processing, regardless of whether the property value is Boolean, long, or character type.
To further understand, you can export a data window and view its original code, and you can see that even the color properties of the column are used with a double primer
Number of numbers to express.
Five How to quickly delete multiple lines in DataWindow
In the development process, you may often have to do multiple-row deletions, generally using the loop statement to do the operation:
For Ll_rowon = 1 to Dw_1.rowcount () Dw_1.deleterow (Ll_rowon) NEXT
A quick way to delete is to move the row you want to delete from the primary buffer to the delete buffer. For example, delete all rows in the buffer:
Dw_1.rowsmove (dw_1, 1, Dw_1.rowcount, primary!, Dw_1, 1, delete!)
But don't forget to filter the rows in a different buffer.
Six How to delete duplicate rows without using the SELECT DISTINCT in DataWindow SQL syntax
First, sort the columns that you want to display a unique value for: "City A", and then add the following filter string: "City < > City [-1] or GetRow () = 1"
Seven How to display the line numbers of each group in DataWindow in grouped form
When we display line numbers for each row of DataWindow, we can simply put an expression in the GetRow () computed column. For grouped DataWindow, however, to display the row numbers for each group, you should use an expression of GetRow ()-The computed column of the GetRow () for Group 1) + 1.
Eight How to change the font color of a column to remind the user that the column has been modified
In the color property 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 in column_name < > column_name. Original compares the values of the current column with the values of the original columns to achieve the purpose of the judgment.
Nine Move a row in a data window, but not a filter or delete operation
The Rowsdiscard () function does this by performing the removal work in the data window, but the removed row cannot be deleted or any modified save.
Ten How to display the line number of the first and last rows of the current data in the footer band in a multiline display DataWindow
Let's look at the expression of two computed columns: IF (GetRow () = First (GetRow () for page), 1, 0)//1 is the top row of the current page
IF (GetRow () < > 1 and GetRow () = (GetRow () for page), 1, 0)//1 is the last row of the current page
It is known from the above that the following computed column expression is set in the footer band:
' Rows ' + string (GetRow () for page) + "to" + string (Last (GetRow () for page) + ' are displayed '
can achieve this function.