Skip to main content

BrickGraphics.DrawLine(PointF, PointF, Color, Single) Method

Adds a specific LineBrick object to a document.

Namespace: DevExpress.XtraPrinting

Assembly: DevExpress.Printing.v22.2.Core.dll

NuGet Packages: DevExpress.Printing.Core, DevExpress.Win.Dashboard.Design


public LineBrick DrawLine(
    PointF pt1,
    PointF pt2,
    Color foreColor,
    float width


Name Type Description
pt1 PointF

A PointF object specifying where the line starts.

pt2 PointF

A PointF object specifying where the line ends.

foreColor Color

A Color object specifying the line’s color.

width Single

A float value specifying the line’s width.


Type Description

A LineBrick object that represents the line drawn in the document.


The line’s width is measured in three hundredths of an inch (1/300).


The following example demonstrates how to draw a line in a Printing System document. The first way to do this is to use the BrickGraphics.DrawLine method, that is specially designed to draw lines easily. In addition, you can use the more common approach, by drawing a LineBrick via the BrickGraphics.DrawBrick method.

The code below illustrates how this can be done.

using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraPrinting;
// ...

namespace LineBrickAndDrawLine {
    public partial class Form1 : Form {
        public Form1() {

        private void Form1_Load(object sender, EventArgs e) {
            printControl1.PrintingSystem = ps;

        private void btnDrawLine_Click(object sender, EventArgs e) {
            // Prepare for creating a document.
            BrickGraphics gr = ps.Graph;
            gr.Modifier = BrickModifier.Detail;

            // Draw a line with the specified coordinates, foreground color and thickness.
            LineBrick brick = gr.DrawLine(new PointF(0, 0), new PointF(200, 200), Color.Red, 5);

            // Change the line style to dash-dot-dot.
            brick.LineStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot;

            // Hide brick borders.
            brick.BorderWidth = 0;

            // Finish creating the document.

        private void btnDrawBrick_Click(object sender, EventArgs e) {
            // Prepare for creating a document.
            BrickGraphics gr = ps.Graph;
            gr.Modifier = BrickModifier.Detail;

            // Create a new line brick.
            LineBrick brick = new LineBrick();

            // Specify its properties.
            brick.Rect = new RectangleF(0, 0, 200, 200);
            brick.LineDirection = DevExpress.XtraReports.UI.LineDirection.BackSlant;
            brick.ForeColor = Color.Red;
            brick.LineWidth = 5;
            brick.LineStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot;
            brick.BorderWidth = 0;

            // Draw this brick.

            // Finish creating the document.

The following code snippets (auto-collected from DevExpress Examples) contain references to the DrawLine(PointF, PointF, Color, Single) method.


The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also