Flexible implementation of Pb [change line color in Grid-style data window] (it can also be a grid data window with a table header)

Source: Internet
Author: User

From: http://www.cnblogs.com/powerbuilder/archive/2012/03/11/2391128.html

 

The data window of the Grid type in PB is the most widely used type. Features: quick creation and easy location adjustment. After running, you can adjust the column width conveniently, column location, the most efficient operation.

However, the line color of the data window type is fixed and cannot be changed (you can modify the memory data through APIS or third-party controls), and the line is not very beautiful, many people are not satisfied with his color. If you want to make a beautiful report PB and provide another type of data window Tabular, you can draw the line by yourself, and the color of the line can also be changed, but the disadvantages of Tabular are also obvious: it is tedious to draw a line. If you want to modify the columns after the line is drawn, this work will be crazy. In addition, the width of the Column cannot be manually scaled or narrowed after running.

Question! Find an existing header, change the line color, and make it easy to modify. After running, you can pull the column width .... . My answer is: create a data window of the Grid type. After the program runs, convert it to the Tabular type. The program automatically strikethroughs it, and then the program controls the mouse to drag the event to pull the width and narrow the column, in this way, the source code of the Grid in the program is not changed, so that modifications to the program are made to the original Grid type, which is faster.

1. Create Nvo nvo_Grid_Report, And the instance variable Left_Add // left offset

2. to drag a Grid column, you must record the position of each column and the position of the drawn line so that the column and line can be correctly moved, create four DS instances:

Ids_Header // record the Header title information, mainly: Object Name, x, width, ID of the corresponding column, line name

Ids_Detail // record the information in Detail, that is, the column and calculation column. Mainly: Object Name, x, width, ID, line name

Ids_ForeGround // This record records multiple headers, because the top header of multiple headers must be set to ForeGround. Object Name, x, corresponding to column Id1, corresponding column ID2 (it is a cross-column), line name

Ids_Summary // The same as ids_Detail

3. added the Of_Get_Objects function to obtain the information in dw, that is, to fill in the four ds in the previous step. In ids_Detail, the ID number is actually a sequence number after sorting by x in details, recording the position of the column. The line name is the name of the line to be drawn. The line of the ids_Header is a vertical line on the right of the title (Text), and the line of the ids_Detail is also the vertical line on the right of the column and the horizontal line below the column

4. Start to draw a line

① First obtain the Syntax of the data window, replace processing = 1 with processing = 0

②. For I = loop ids_detail, generate two variables ls_lines (this is the line syntax that needs to be created), ls_modify (this is the X of the last modified column)

Example: = 10

Ls_lines + = line (vertical line X1 = x2 = Column 10. column x + 10. width + left_add) (Y1 =-4, y2 = detail. heigth + 4) (name, color)

Ls_lines + = line (horizontal line X1 = Column 10. X + left_add, X2 = Column 10. X + left_add + Column 10. width) (Y1 = Y2 = detail. height-4) (name, color)

Ls_modify + = Column 10 + ". x =" + Column 10 x + Left + add

Then, find the title corresponding to Column 10 and obtain the Lines expression and Modify expression corresponding to the title.

Then, find the Summary corresponding to Column 10. If there is a Summary area, the line will be drawn no matter whether or not the Summary calculation corresponding to Column 10 is found.

Then, the Foreground object corresponding to the tenth column is taken. This object is special and complicated to process across multiple columns. Its position and line width must be specially processed.

③. The syntax generated by the location of the corresponding point column and line has been passed in step 2. Here, we need to add several special objects.

1. A line above the title and a line below the title in the Header

2. If there is a Summary, draw a horizontal line below it.

3. A plug-in line on the left

4. Draw a point in 20 pixels on the right of the rightmost column. The main purpose is to display the line on the rightmost. Otherwise, the line cannot be displayed.

④. If there is a header, you should also create the syntax. Here, note that there is a header, then the line in the header area and the y in the header area are changed, and the outbound position is given to the header.

⑤. Add the lines Syntax to the original Syntax, execute dw_1.Create (), and then run dw_1.Modify (ls_Modify) to change the Grid data window to a Tabular style.

5. process column Movement

1. Click the mouse to determine whether the object in the vertex is the line on the right of the title.

2. If the line on the right of the title is to move the mouse (the mouse does not show up), the basic principle is as follows:

1. The title of the line and the corresponding column and the width of the summary column are changed, and x is not changed.

2. All objects after this line x +, with the same width

3. Several fixed lines. The line x2 in the title is to be changed.

6. The general effect is as follows:

Original Grid running effect

Effect after transformation

 

After changing the color

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.