Report.Line 方法 (Access)Report.Line method (Access)

Line方法繪製線條和矩形Report物件上Print事件發生時。The Line method draws lines and rectangles on a Report object when the Print event occurs.


運算式線條步驟(x1、 y1)-步驟(x2、 y2)、色彩 BFexpression.Line (Step (x1, y1) - Step (x2, y2), Color, BF)

需要 expressionexpression Required. 代表**Report** 物件的變數。A variable that represents a Report object. 可傳回 [套用至]**** 清單內其中一個物件的運算式。An expression that returns one of the objects in the Applies To list.


名稱Name 資料類型Data type 描述Description
步驟Step 關鍵字Keyword 會指出的起始點座標是相對於_Object_引數的**CurrentX** 和**CurrentY** 屬性的目前設定所提供的目前圖形位置。Indicates that the starting point coordinates are relative to the current graphics position given by the current settings for the CurrentX and CurrentY properties of the Object argument.
x1、 y1x1, y1 SingleSingle 會指出直線或矩形的起始點的座標。Indicates the coordinates of the starting point for the line or rectangle. _物件_引數所指定的Report物件的縮放比例屬性 (ScaleModeScaleLeftScaleTopScaleHeight、 及ScaleWidth) 決定所使用的度量單位。The Scale properties (ScaleMode, ScaleLeft, ScaleTop, ScaleHeight, and ScaleWidth) of the Report object specified by the Object argument determine the unit of measure used. 如果省略此引數,則線條開始CurrentXCurrentY屬性所指定的位置。If this argument is omitted, the line begins at the position indicated by the CurrentX and CurrentY properties.
x2、 y2x2, y2 SingleSingle 必要項目。Required. 會指出直線或矩形的結束點的座標。Indicates the coordinates of the ending point for the line or rectangle. 請確定的起點和終點會以連字號 (-) 隔開。Ensure that the starting point and the ending point are separated by a hyphen ( - ).
ColorColor LongLong 會指出用來繪製線條 RGB (紅-綠-藍) 色彩。Indicates the RGB (red-green-blue) color used to draw the line. 如果省略此引數,則會使用 ForeColor 屬性的值。If this argument is omitted, the value of the ForeColor property is used. 您也可以使用 RGB 函數或 QBColor 函數來指定色彩。You can also use the RGB function or QBColor function to specify the color.
BB 以建立矩形使用座標做為對角矩形的選項。An option that creates a rectangle by using the coordinates as opposite corners of the rectangle.
FF F_無法使用無_B。如果使用 [ B ] 選項,則_F_選項指定矩形的填滿繪製矩形時所使用的同一個色彩。F cannot be used without B. If the B option is used, the F option specifies that the rectangle is filled with the same color used to draw the rectangle. 如果僅使用 B 而未使用 F,則會以 FillColorBackStyle 屬性之目前設定所指定的色彩填滿矩形。If B is used without F, the rectangle is filled with the color specified by the current settings of the FillColor and BackStyle properties. BackStyle 屬性的矩形和線條預設值為 [一般]。The default value for the BackStyle property is Normal for rectangles and lines.


您可以使用此方法只能在事件程序或 [報告] 區段的 OnPrintOnFormat 事件屬性或報表的 OnPage 事件屬性所指定的巨集。You can use this method only in an event procedure or a macro specified by the OnPrint or OnFormat event property for a report section, or the OnPage event property for a report.

若要連接兩條繪圖線,請確定其中一條繪圖線是從上一個線條的結束點開始。To connect two drawing lines, make sure that one line begins at the end point of the previous line.

繪製的線條寬度取決於**DrawWidth** 屬性設定值。The width of the line drawn depends on the DrawWidth property setting. 直線或矩形在背景中繪製的方式取決於**DrawMode** 和**DrawStyle** 屬性的設定。The way a line or rectangle is drawn on the background depends on the settings of the DrawMode and DrawStyle properties.

當您套用Line方法時, CurrentXCurrentY屬性會重新設定為_x2_和_y2_引數所指定的結束點。When you apply the Line method, the CurrentX and CurrentY properties are re-set to the end point specified by the x2 and y2 arguments.


下列範例使用Line方法繪製紅色的矩形五個像素為單位名為EmployeeReport的報表邊緣內。The following example uses the Line method to draw a red rectangle five pixels inside the edge of a report named EmployeeReport. RGB 函數用來將線條標示為紅色。The RGB function is used to make the line red.

若要嘗試此範例會在 Microsoft Access 中的,建立名為EmployeeReport的新報表。To try this example in Microsoft Access, create a new report named EmployeeReport. 下列程式碼貼在報表的模組的宣告區段中,然後切換至預覽列印]。Paste the following code in the Declarations section of the report's module, and then switch to Print Preview.

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer) 
    ' Call the Drawline procedure 
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

支援和意見反應Support and feedback

有關於 Office VBA 或這份文件的問題或意見反應嗎?Have questions or feedback about Office VBA or this documentation? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.