.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
The page you are viewing does not exist in the .NET Standard 2.0+ platform documentation. This link will take you to the parent topic of the current section.
A newer version of this page is available.

SubDocument.CreateCustomMark(DocumentPosition, Object) Method

Obsolete. Creates a custom mark at the specified position and associates specified data with it.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v19.1.Core.dll


[Obsolete("This method has become obsolete. Use the 'DevExpress.XtraRichEdit.API.Native.CustomMarkCollection.Create(DocumentPosition position, object userData)' method instead.")]
CustomMark CreateCustomMark(
    DocumentPosition position,
    object userData


Name Type Description
position DocumentPosition

A DocumentPosition specifying the position being marked.

userData Object

An arbitrary object that will be associated with the created mark.


Type Description

A CustomMark object representing a position marker in the document.


Use the SubDocument.CreateCustomMark method to create a mark, add it to the SubDocument.CustomMarks collection and visualize it by handling the RichEditControl.CustomMarkDraw event.


A custom mark is linked to a certain text run, and moves with the content if a text is deleted or inserted before the marked position. It is not saved when the document is exported to any format, and you should provide a way to create it again when a document is loaded.


This code snippet illustrates the use of the SubDocument.CreateCustomMark method and the RichEditControl.CustomMarkDraw event, to add a mark to the selection and draw its visual representation.

Imports DevExpress.XtraRichEdit.API.Native
Imports DevExpress.XtraRichEdit.Layout.Export
Imports System.Drawing.Drawing2D
        Private Sub btn_Mark_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_Mark.Click
            Dim doc As Document = richEditControl1.Document
            Dim m As CustomMark = doc.CustomMarks.Create(doc.Selection.Start, Color.DarkOrange)
        End Sub

        Private Sub richEditControl1_CustomMarkDraw(ByVal sender As Object, ByVal e As DevExpress.XtraRichEdit.RichEditCustomMarkDrawEventArgs) Handles richEditControl1.CustomMarkDraw
            For Each info As CustomMarkVisualInfo In e.VisualInfoCollection
                Dim doc As Document = richEditControl1.Document
                Dim mark As CustomMark = doc.CustomMarks.GetByVisualInfo(info)
                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias

                Dim curColor As Color = CType(info.UserData, Color)
                If mark.Position < doc.Selection.Start Then
                    curColor = Color.Green
                End If
                    Dim p As New Pen(curColor, 3)
                    p.StartCap = LineCap.Flat
                    p.EndCap = LineCap.ArrowAnchor
                    e.Graphics.DrawLine(p, New Point(0, info.Bounds.Y), info.Bounds.Location)
            Next info
        End Sub
See Also