在打印报表的时候,我们会看见文本框有些内容不显示。因为文本框没有足够大的时候,部分内容会自动遮挡了。
下面的示例是报表文本框并行同步扩大。即文本框随着文字的多少而自动扩大或者缩放,如图所示
详细源码:
Private Sub 页面页眉_Print(Cancel As Integer, PrintCount As Integer)
Me.ScaleMode = 1 '设定计量单位 缇
Me.Line (ScaleLeft, ScaleTop)-(ScaleWidth, ScaleHeight), RGB(0, 0, 0), B
Me.Line (Labe1.Left, ScaleTop)-(Labe1.Left, ScaleHeight), RGB(0, 0, 0)
Me.Line (Labe2.Left, ScaleTop)-(Labe2.Left, ScaleHeight), RGB(0, 0, 0)
End Sub
Private Sub 主体_Format(Cancel As Integer, FormatCount As Integer)
Dim L As Long
Dim inC As Integer
Dim ctl As Access.Control
L = 0
strName = ""
Me.ScaleMode = 1
inC = Text1.Section '用控件的父属性,确定报表节
For Each ctl In Section(inC).Controls
If Abs(Int(TextWidth(ctl) / ctl.Width * -1)) > L Then L = Abs(Int(TextWidth(ctl) / ctl.Width * -1)): strName = ctl.Name
Next ctl
For Each ctl In Section(inC).Controls
If (ctl.Name <> strName) Then
ctl.TopMargin = (L - Abs(Int(TextWidth(ctl) / ctl.Width * -1))) * ctl.Height / 2 + ctl.Height / 2
Else
ctl.TopMargin = ctl.Height / 2
End If
Next ctl
End Sub
Private Sub 主体_Print(Cancel As Integer, PrintCount As Integer)
Dim inC As Integer
Me.ScaleMode = 1
inC = Text1.Section
Me.Line (ScaleLeft, ScaleTop)-(ScaleWidth, Me(strName).Height), RGB(0, 0, 0), B
Me.Line (Text1.Left, ScaleTop)-(Text1.Left, Me(strName).Height), RGB(0, 0, 0)
Me.Line (Text2.Left, ScaleTop)-(Text2.Left, Me(strName).Height), RGB(0, 0, 0)
Me.sL0.Visible = Section(inC).WillContinue
End Sub