RichEditControl.CustomMarkDraw Event
Fires before a custom mark is painted, and enables you to visualize the custom mark as required.
Namespace: DevExpress.XtraRichEdit
Assembly: DevExpress.XtraRichEdit.v18.1.dll
Declaration
Event Data
The CustomMarkDraw event's data class is RichEditCustomMarkDrawEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Graphics | Gets an object used for painting. |
VisualInfoCollection | Provides access to information required to visualize custom marks. |
Remarks
Use the SubDocument.CreateCustomMark method to create a mark, add it to the SubDocument.CustomMarks collection and visualize it by handling the CustomMarkDraw event.
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.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-draw-custom-marks-in-the-document-e2590
using DevExpress.XtraRichEdit.API.Native;
using DevExpress.XtraRichEdit.Layout.Export;
using System.Drawing.Drawing2D;
private void btn_Mark_Click(object sender, EventArgs e)
{
Document doc = richEditControl1.Document;
CustomMark m = doc.CustomMarks.Create(doc.Selection.Start, Color.DarkOrange);
}
private void richEditControl1_CustomMarkDraw(object sender, DevExpress.XtraRichEdit.RichEditCustomMarkDrawEventArgs e)
{
foreach (CustomMarkVisualInfo info in e.VisualInfoCollection)
{
Document doc = richEditControl1.Document;
CustomMark mark = doc.CustomMarks.GetByVisualInfo(info);
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
Color curColor = (Color)info.UserData;
if (mark.Position < doc.Selection.Start) curColor = Color.Green;
Pen p = 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);
}
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the CustomMarkDraw event.
Note
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.