Line 方法

expandtri全部显示

Line 方法用于当 Print 事件发生时,在 Report 对象上画线条或矩形。

expression.Line(flags, x1, y1, x2, y2, color)

expression     必需。返回“应用于”列表中的一个对象的表达式。

flags     必需 Integer 型。

x1    必需 Single 型。该值是线条或矩形起点的坐标。所用的度量由 object   参数指定的 Report 对象的 Scale 属性(ScaleMode, ScaleLeftScaleTopScaleHeightScaleWidth)来确定。。如果忽略该参数,线条从 CurrentX 属性指定的位置开始。

y1    必需 Single 型。该值是线条或矩形起点的坐标。所用的度量由 object   参数指定的 Report 对象的 Scale 属性(ScaleModeScaleLeftScaleTopScaleHeightScaleWidth)来确定。如果忽略该参数,线条从 CurrentY 属性指定的位置开始。

x2     必需 Single 型。其值是所画线条终点的坐标。该参数是必需的。

y2     必需 Single 型。其值是所画线条终点的坐标。该参数是必需的。

color     必需 Long 型。其值是用于画线的 RGB(红绿蓝)颜色。如果忽略该参数,则使用 ForeColor 属性的值。也可以使用 RGB 函数或 QBColor 函数指定颜色。

说明

只能在由报表节的 OnPrintOnFormat 事件属性或报表的 OnPage 事件属性所指定的事件过程中使用该属性。

若要连接两条正在绘制的线条,请确保后一条线以前一条线的终点作为起点。

线条的绘制宽度取决于 DrawWidth 属性设置。线条或矩形在背景上的作图方式取决于 DrawModeDrawStyle 属性的设置。

应用 Line 方法时,CurrentXCurrentY 属性设为 x2y2 参数指定的终点。

示例

下面的示例使用 Line 方法,在名为 EmployeeReport 的报表中,距边缘五个像素处画一个红色的矩形。RGB 函数用于将线条变为红色。

要在 Microsoft Access 中试用该示例,请先创建一个名为 EmployeeReport 新报表。将下列代码粘贴到该报表模块的声明节中,然后切换到“打印预览”。

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

    ' Call the Drawline procedure

    DrawLine

End Sub

Sub DrawLine()

    Dim rpt As Report, lngColor As Long

    Dim sngTop As Single, sngLeft As Single

    Dim sngWidth As Single, sngHeight As Single

    Set rpt = Reports!EmployeeReport

    ' Set scale to pixels.

    rpt.ScaleMode = 3

    ' Top inside edge.

    sngTop = rpt.ScaleTop + 5

    ' Left inside edge.

    sngLeft = rpt.ScaleLeft + 5

    ' Width inside edge.

    sngWidth = rpt.ScaleWidth - 10

    ' Height inside edge.

    sngHeight = rpt.ScaleHeight - 10

    ' Make color red.

    lngColor = RGB(255,0,0)

    ' Draw line as a box.

    rpt.Line(sngTop, sngLeft) - (sngWidth, sngHeight), lngColor, B

End Sub