使用 CurrentX 和 CurrentY 屬性可以指定報(bào)表中進(jìn)行的下一個(gè)打印和繪圖方法起始位置的水平和垂直方向坐標(biāo)。
expression.CurrentX
expression 必需。返回“應(yīng)用于”列表中的一個(gè)對(duì)象的表達(dá)式。
例如,可以使用這些屬性決定在報(bào)表節(jié)中繪制圓的圓心位置。
CurrentX 屬性指定的是一個(gè) Single 值,該值用于一個(gè)數(shù)值表達(dá)式中,以設(shè)置下一個(gè)打印和繪圖方法起始位置的水平坐標(biāo)。
坐標(biāo)值從報(bào)表節(jié)的左上角開(kāi)始度量,該報(bào)表節(jié)的左上角為 CurrentX 或 CurrentY 屬性的參照坐標(biāo)。在節(jié)的左邊界 CurrentX 屬性設(shè)為 0,在它的上邊界 CurrentY 屬性設(shè)為 0。
可以使用報(bào)表節(jié)的 OnPrint 屬性設(shè)置指定的宏來(lái)設(shè)置這兩屬性,或者使用 Visual Basic 事件過(guò)程來(lái)設(shè)置 CurrentX 和 CurrentY 屬性。
使用 ScaleMode 屬性可定義度量單位,例如磅、像素 、字符、英寸、毫米或厘米。
在使用下列圖形方法時(shí),CurrentX 和 CurrentY 屬性設(shè)置的更改如下。
方法 |
CurrentX、CurrentY 屬性設(shè)置為 |
對(duì)象的中央。 |
|
線條的終點(diǎn) (x2、y2 坐標(biāo))。 |
|
下一個(gè)打印位置。 |
以下示例使用 Print 方法來(lái)顯示名為“報(bào)表1”的報(bào)表上的文本。它使用 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