1. Preface
In PowerBuilder, The datawindow technology is the core of Pb, so that Sybase even applied for a patent for it. Almost all operations on the data in the database are performed through the datawindow object. The creation of the data window object directly affects the advantages and disadvantages of the application.
For many programmers who are new to PowerBuilder, the difference between datawindow controls and datawindow objects is often confusing. In fact, the datawindow control is a control similar to the checkbox and commandbutton controls. The datawindow object is the object created in the PBL library using the drawing board. Compared with the datawindow object, the datawindow control is like a container to include it in the control.
Some data window usage skills that are often used in actual use. Now let's talk about the commonly used technique of displaying the color compartment in the data window.
2. Function Description
Data windows often return many records after retrieve, and the data in these records is complex, which usually causes visual inconvenience. Therefore, if the rows and rows can be distinguished by different colors, for example, the background color of the first record is light white, the background color of the second record is light gray, and the third row is light white, the fourth line is light gray ...... And so on, which greatly facilitates users and adds a lot of colors to your applications. At the same time, when the user clicks the current row, the color will become light yellow, and everyone will like this effect.
3. Implementation Method
To make the displayed data achieve the above results, we should first know where these representations should be reflected in the data window objects. Obviously, all data in the data window is listed in the detail band, so you only need to set the column object (column) in the detail band) will affect its display effect. The specific implementation is as follows:
Open the data window and select all columns ).
Go to the font tab in the Properties window and click a small button with a red icon next to the background color attribute. See the figure 7.1.
Enter in the expression column (see Figure 7.2 ):
| If (currentrow () = getrow (), RGB (255,240,194), if (mod (getrow (), 2) = 1, & RGB (255,254,249), RGB (247,247,239 ))) |
Figure 7.2 input expression |
Note:
In the expression, RGB (255,240,194) is light yellow, RGB (255,254,249) is light white, and RGB (247,247,239) is light yellow.
4. effect display
Return to the preview window and check whether the effect is quite good! See the Figure 7.3.
5. Related Function Description
The currentrow () and getrow () functions are data window information functions.
1. currentrow ()
Function Description: obtains the row number of the row with the current input focus in the data window.
Syntax: currentrow ()
Return Value: Long. When the function is successfully executed, the row number of the current row is returned, and 0 is returned if no current row exists.
2. getrow ()
Function Description: return the row number in the corresponding section of the data window.
Syntax: getrow ()
Return Value: Long. If the function is successfully executed, the corresponding row number with the current row is returned. If there is no data in the data window, 0 is returned, and-1 is returned when an error occurs.