Skip to main content
Box

PageCanvas.DrawRectangle(RichEditPenBase, Int32, Int32, Int32, Int32, DocumentLayoutUnit) Method

Draws a custom rectangle.

Namespace: DevExpress.XtraRichEdit.API.Layout

Assembly: DevExpress.RichEdit.v23.2.Core.dll

NuGet Packages: DevExpress.RichEdit.Core, DevExpress.Win.Navigation

Declaration

public void DrawRectangle(
    RichEditPenBase pen,
    int x,
    int y,
    int width,
    int height,
    DocumentLayoutUnit unit
)

Parameters

Name Type Description
pen RichEditPenBase

RichEditPenBase descendant that sets the outline color and thickness.

x Int32

Sets the x-coordinate of the shape’s upper-left corner.

y Int32

Sets the y-coordinate of the shape’s upper-left corner.

width Int32

Sets the shape’s width.

height Int32

Sets the shape’s height.

unit DocumentLayoutUnit

Specifies measurement units for shape parameters.

Remarks

To set the line style of the pen, use the RichEditPenBase.DashStyle method.

When you print or export documents, document objects may appear differently from the way they look on screen. To make them look the same in both outputs, set the DocumentLayoutUnit parameter to the same DocumentLayoutUnit value as the one specified for the document layout.

Note

Using this parameter is effective only if the drawn shape has coordinates and parameters represented by absolute values – coordinates represented by relative values already have the same measurement unit as the whole document layout.

Example

This code snippet illustrates the implementation of the PageCanvas.DrawRectangle and PageCanvas.DrawLine methods. They draw a color rectangle and two crossed lines in place of the inline pictures.

View Example

Public Overrides Sub DrawInlinePictureBox(ByVal inlinePictureBox As InlinePictureBox)
    If Form1.customDrawPicture = True Then
        Dim Ebounds As Rectangle = inlinePictureBox.Bounds
        Dim pen As New RichEditPen(Color.Maroon, 2)
        pen.DashStyle = RichEditDashStyle.Dot
        Canvas.DrawLine(pen, New Point(Ebounds.X, Ebounds.Y + Ebounds.Height), New Point(Ebounds.X + Ebounds.Width, Ebounds.Y))
        Canvas.DrawLine(pen, New Point(Ebounds.X, Ebounds.Y), New Point(Ebounds.X + Ebounds.Width, Ebounds.Y + Ebounds.Height))
        Dim inlineRect As New Rectangle(Ebounds.X, Ebounds.Y, Ebounds.Width, Ebounds.Height)
        Canvas.DrawRectangle(New RichEditPen(Color.Aquamarine, 4), inlineRect)
    Else
        MyBase.DrawInlinePictureBox(inlinePictureBox)
    End If
End Sub
See Also