Dim PHSec2_RptLbl_Collection As New Collection '页标头(PageHeader)区域 Label(RptLabel) 控件集合
Dim DSec1_RptLbl_Collection As New Collection '细节(Detail)区域 Label(RptLabel) 控件集合
Dim PFSec3_RptLbl_Collection As New Collection '页注脚(PageFooter)区域 Label(RptLabel) 控件
Dim PHSec2_RptShp_Collection As New Collection '页标头(PageHeader)区域 Shape(RptShape) 控件集合
Dim DSec1_RptShp_Collection As New Collection '细节(Detail)区域 Shape(RptShape) 控件集合
Dim PFSec3_RptShp_Collection As New Collection '页注脚(PageFooter)区域 Shape(RptShape) 控件集合
Dim DSec1_RptTxt_Collection As New Collection '细节(Detail)区域 TextBox(RptTextBox) 控件集合
'TextBox (RptTextBox) 控件只能绘制到细节(Detail)区域
Dim PHSec2_RptImg_Collection As New Collection '页标头(PageHeader)区域 Image(RptImage) 控件集合
Dim DSec1_RptImg_Collection As New Collection '细节(Detail)区域 Image(RptImage) 控件集合
Dim PFSec3_RptImg_Collection As New Collection '页注脚(PageFooter)区域 Image(RptImage) 控件集合
Dim PHSec2_RptLine_Collection As New Collection '页标头(PageHead)区域 Line(RptLine) 控件集合
Dim DSec1_RptLine_Collection As New Collection '细节(Detail)区域 Line(RptLine) 控件集合
Dim PFSec3_RptLine_Collection As New Collection '页注脚(PageFooter)区域 Line(RptLine) 控件集合
Dim Ctl 'As Object
For Each Ctl In DataReport1.Sections.Item("Section2").Controls 'Section2
Select Case TypeName(Ctl)
Case "RptLabel"
PHSec2_RptLbl_Collection.Add Ctl
Ctl.Caption = ""
Case "RptShape"
PHSec2_RptShp_Collection.Add Ctl
Case "RptLine"
PHSec2_RptLine_Collection.Add Ctl
Case "RptImage"
PHSec2_RptImg_Collection.Add Ctl
End Select
Ctl.Left = 0
Ctl.Top = 0
Ctl.Height = 300
Ctl.Width = (Rnd + 1) * 600
Ctl.Visible = False
Next Ctl
For Each Ctl In DataReport1.Sections.Item("Section1").Controls 'Section1
Select Case TypeName(Ctl)
Case "RptLabel"
DSec1_RptLbl_Collection.Add Ctl
Ctl.Caption = ""
Case "RptShape"
DSec1_RptShp_Collection.Add Ctl
Case "RptTextBox"
Ctl.DataField = adoRecordsetX.Fields.Item(0).Name '先将所有TextBox(RptTextBox) 控件绑定到某一字段
'否则报错!
DSec1_RptTxt_Collection.Add Ctl
Case "RptLine"
DSec1_RptLine_Collection.Add Ctl
Case "RptImage"
DSec1_RptImg_Collection.Add Ctl
End Select
Ctl.Left = 0
Ctl.Top = 0
Ctl.Height = 400
Ctl.Width = 600
Ctl.Visible = False
Next Ctl
For Each Ctl In DataReport1.Sections.Item("Section3").Controls 'Section3
Select Case TypeName(Ctl)
Case "RptLabel"
PFSec3_RptLbl_Collection.Add Ctl
Ctl.Caption = ""
Case "RptShape"
PFSec3_RptShp_Collection.Add Ctl
Case "RptLine"
PFSec3_RptLine_Collection.Add Ctl
Case "RptImage"
PFSec3_RptImg_Collection.Add Ctl
End Select
Ctl.Left = 0
Ctl.Top = 0
Ctl.Height = 400
Ctl.Width = (Rnd + 1) * 600
Ctl.Visible = False
Next Ctl