使用 CurrentX 和 CurrentY 屬性可以指定報表中進行的下一個打印和繪圖方法起始位置的水平和垂直方向坐標(biāo)。
expression.CurrentX
expression 必需。返回“應(yīng)用于”列表中的一個對象的表達式。
例如,可以使用這些屬性決定在報表節(jié)中繪制圓的圓心位置。
CurrentX 屬性指定的是一個 Single 值,該值用于一個數(shù)值表達式中,以設(shè)置下一個打印和繪圖方法起始位置的水平坐標(biāo)。
坐標(biāo)值從報表節(jié)的左上角開始度量,該報表節(jié)的左上角為 CurrentX 或 CurrentY 屬性的參照坐標(biāo)。在節(jié)的左邊界 CurrentX 屬性設(shè)為 0,在它的上邊界 CurrentY 屬性設(shè)為 0。
可以使用報表節(jié)的 OnPrint 屬性設(shè)置指定的宏來設(shè)置這兩屬性,或者使用 Visual Basic 事件過程來設(shè)置 CurrentX 和 CurrentY 屬性。
使用 ScaleMode 屬性可定義度量單位,例如磅、像素 、字符、英寸、毫米或厘米。
在使用下列圖形方法時,CurrentX 和 CurrentY 屬性設(shè)置的更改如下。
以下示例使用 Print 方法來顯示名為“報表1”的報表上的文本。它使用 TextWidth 和 TextHeight 方法,使文本在垂直和水平方向上居中。
Private Sub Detail_Format(Cancel As Integer, _
FormatCount As Integer)
Dim rpt as Report
Dim strMessage As String
Dim intHorSize As Integer, intVerSize As Integer
Set rpt = Me
strMessage = "DisplayMessage"
With rpt
'Set scale to pixels, and set FontName and
'FontSize properties.
.ScaleMode = 3
.FontName = "Courier"
.FontSize = 24
End With
' Horizontal width.
intHorSize = Rpt.TextWidth(strMessage)
' Vertical height.
intVerSize = Rpt.TextHeight(strMessage)
' Calculate location of text to be displayed.
Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
' Print text on Report object.
Rpt.Print strMessage
End Sub