DataWindow style helps you format data window styles

Source: Internet
Author: User
Tags format constant count header implement integer return window
window| data
DataWindow style helps you format data window styles

Author: Bad person Zhang, Published time: 2004-9-19

When using DataWindow, we usually manually adjust the style of the Data Window object (column width, Liegau, caption, color, and so on) in the Data window artboard. But in large applications, there are often a number of data windows, and repeated manual to adjust these data window will bring great inconvenience to our development work, even if the patient one by one modifies the data Window object's style, also unavoidably cannot achieve the precise unification, such namely does not conform to the function reuse the spirit, Also bring certain influence to the system's use effect.

In order to solve this problem very well, this solution is proposed, this scenario is specifically for the grid type of data window, in which the code traverses all the visual columns of the Data window, changing the style of columns and column headings, and changing the style of the data window in the column that owns the Drop-down data window. To achieve the purpose of formatting the data window style.

You can see the final effect of this function in the following illustration:





Figure 1. DataWindow Style Effect Sample

Implementation mechanism:

1. The first is to have a data window base class, as a future package of various data window related to the characteristics of the Code container.

2. All attributes of the Dwobject to be formatted need to be set to the form of a variable and assigned a value to them.

3. Use the describe ("DataWindow.Column.Count") function to get the number of columns in the Data window and traverse the column, using the Modify ("") function to implement the change dwobject its associated properties (for example: Execute modify ("id_t"). Font.face= ' song body ') to change the font of the id_t.

4. Repeat 3 of the process, but the difference is that this traversal is the Data window column, that is, Datawindowchild object, note: Do not forget to first determine whether the data window has datawindowchild, some words remember to get them first.

5. Also the last step, do you need to save the style of the data window? (For example: Keep the same column width, the next time you open this window, you can maintain the same width as the last adjustment.) Here is just a reminder, as to how to achieve the specific, this example does not make a statement, perhaps later there is a special topic on the system configuration to explain it.

Main code implementation:

1. Declaration of variables:

Private
Integer Ii_style = 1//Default style

Constant integer Style_default = 1

Style_default
Constant string colheader_fontcolor_default = "16777215"
Constant string colheader_bgcolor_default = "10040064"
Constant string col_bgcolor_default= "536870912~tif (mod (GetRow (), 2) =0,rgb (239,236,229), RGB (255,255,255))"

2. Main function:

1) integer of_getchild (ref datawindowchild adwc[])

Integer i, J, li_col_cnt
Integer Li_ret
String Ls_col
Datawindowchild ldwc_child[]

li_col_cnt = Integer (This.describe ("DataWindow.Column.Count"))

If li_col_cnt < 1 then return-1

For i = 1 to li_col_cnt
Ls_col = This.of_getcolumndisplayname (i)
Li_ret = This.getchild (Ls_col, Ldwc_child[i])
If Li_ret = 1 Then
J + +
This.getchild (Ls_col, Adwc[j])
End If
Next

Return J

2) string Of_getcolumndisplayname (integer ai_colnumber)

String Ls_colname

Ls_colname = This.describe ("#" + string (ai_colnumber) + ". Name")
If Ls_colname = "" or Ls_colname = "!" Then
Return "!"
End If

Return Of_getcolumndisplayname (Ls_colname)

3) string Of_getcolumndisplayname (String as_colname)

String Ls_coldisplayname

Ls_coldisplayname = This.describe (As_colname + ". Name")

Return Ls_coldisplayname

4) string Of_getheadername (String as_column)

String ls_defaultheadersuffix = "_t"
String Ls_colhead

Ls_colhead = As_column + ls_defaultheadersuffix

Return Ls_colhead

5) string Of_getheadertext (String as_column)

String ls_defaultheadersuffix = "_t"
String Ls_colhead

Ls_colhead = This.describe (as_column + Ls_defaultheadersuffix + ". Text ")
If Ls_colhead = "!" Then
No Valid column header, use column name.
Ls_colhead = As_column
End If

Return Ls_colhead

6) Integer of_setstyle (integer ai_style)

Integer I, j
Integer li_column_cnt//Number of columns
String ls_column_name//Column name
String ls_column_width//Column width
String Ls_child_column_name//Child Data Window column name
String ls_column_headername//column headers
String ls_colheader_fontcolor//column header font Color
String ls_colheader_bgcolor//column header background color
String Ls_col_bgcolor//column background color
Datawindowchild ldwc_child[]//Child Data window

Choose Case Ai_style
Case 1
Ls_colheader_fontcolor = Colheader_fontcolor_default
Ls_colheader_bgcolor = Colheader_bgcolor_default
Ls_col_bgcolor = Col_bgcolor_default
Case Else
Ls_colheader_fontcolor = Colheader_fontcolor_default
Ls_colheader_bgcolor = Colheader_bgcolor_default
Ls_col_bgcolor = Col_bgcolor_default
End Choose

Prohibit column movement
This.modify ("Datawindow.grid.columnmove=no")
Disable full mouse selection
This.modify ("Datawindow.selected.mouse=no")
Adjust columns and column headings
li_column_cnt = Integer (This.describe ("DataWindow.Column.Count"))

For i = 1 to li_column_cnt
Adjust column styles
Ls_column_name = This.of_getcolumndisplayname (i)

This.modify (Ls_column_name + ". Font.face= ' song Body ')
This.modify (Ls_column_name + ". Font.height= '-9 ' ")
This.modify (Ls_column_name + ". y= ' 4 ' ")
This.modify (Ls_column_name + ". Height= ' 56 ' ")
This.modify (Ls_column_name + ". Background.mode= ' 0 ' ")
This. Modify (Ls_column_name + ". Background.color= ' "+ Ls_col_bgcolor +" "")
Adjust column heading styles
Ls_column_headername = This.of_getheadername (ls_column_name)

This.modify (Ls_column_headername + ". Color= ' "+ Ls_colheader_fontcolor +" "")
This.modify (Ls_column_headername + ". Font.face= ' Arial ' ")
This.modify (Ls_column_headername + ". Font.height= '-9 ' ")
This.modify (Ls_column_headername + ". y= ' 0 ' ")
This.modify (Ls_column_headername + ". height= ' 68 ' ")
This.modify (Ls_column_headername + ". Background.mode= ' 0")
This.modify (Ls_column_headername + ". Background.color= ' "+ Ls_colheader_bgcolor +" "")
Next

Stripe style
This.modify ("datawindow.header.height= ' 68")
This.modify ("datawindow.detail.height= ' 68")
This.modify ("datawindow.footer.height= ' 40")

This.modify ("datawindow.footer.color= '" + Ls_colheader_bgcolor + "")

Adjust Datawindowchild style
This.of_getchild (ldwc_child[])

For i = 1 to Upperbound (Ldwc_child)
If IsValid (Ldwc_child[i]) then
Ldwc_child[i].settransobject (SQLCA)
Prohibit column movement
Ldwc_child[i].modify ("Datawindow.grid.columnmove=no")
Disable full mouse selection
Ldwc_child[i].modify ("Datawindow.selected.mouse=no")
Resize table Head height to 0
Ldwc_child[i].modify ("datawindow.header.height= ' 0")
Resize Data area height
Ldwc_child[i].modify ("datawindow.detail.height= ' 68")
Number of Datawindowchild columns
li_column_cnt = Integer (Ldwc_child[1].describe ("DataWindow.Column.Count"))
Adjust column styles for Datawindowchild
For j = 1 to Li_column_cnt
Adjust column styles
Ls_child_column_name = Ldwc_child[i].describe ("#" + string (j) + ". Name")

If Ls_child_column_name = "" or Ls_child_column_name = "!" Then
Ls_child_column_name = ' '
Else
Ls_child_column_name = Ldwc_child[i].describe (Ls_child_column_name + ". Name")
End If

Ldwc_child[i].modify (Ls_child_column_name + ". Font.face= ' song Body ')
Ldwc_child[i].modify (Ls_child_column_name + ". Font.height= '-9 ' ")
Ldwc_child[i].modify (Ls_child_column_name + ". y= ' 4 ' ")
Ldwc_child[i].modify (Ls_child_column_name + ". Height= ' 56 ' ")
Ldwc_child[i].modify (Ls_child_column_name + ". Background.mode= ' 0 ' ")
Ldwc_child[i]. Modify (Ls_child_column_name + ". Background.color= ' "+ Ls_col_bgcolor +" "")
Next
End If
Next

Return 1

So far, you have detailed how to implement the use of code to unify the data window style, you only need to add to your base class, if you have any questions or better way, welcome to contact me!




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.