Skip to main content

DevExpress v24.1 Update — Your Feedback Matters

Our What's New in v24.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

RichEditControl.CustomDrawActiveView Event

Occurs before the active RichEdit view is displayed, and enables you to draw graphics on the document area.

Namespace: DevExpress.XtraRichEdit

Assembly: DevExpress.XtraRichEdit.v24.1.dll

NuGet Packages: DevExpress.Win.PivotGrid, DevExpress.Win.RichEdit, DevExpress.Win.TreeMap

#Declaration

public event RichEditViewCustomDrawEventHandler CustomDrawActiveView

#Event Data

The CustomDrawActiveView event's data class is RichEditViewCustomDrawEventArgs. The following properties provide information specific to this event:

Property Description
Cache Gets an object specifying the storage for the most used pens, fonts and brushes.

#Remarks

Event handler gets access to the RichEditViewCustomDrawEventArgs object which contains graphic resources.

The following code snippet handles the RichEditControl.CustomDrawActiveView event to draw the text “READ ONLY” on the surface of the RichEditControl view.

CustomDrawActiveView

private void richEditControl_CustomDrawActiveView(object sender, RichEditViewCustomDrawEventArgs e)
{
    using (StringFormat sf = new StringFormat())
    {
        sf.Alignment = StringAlignment.Center;
        sf.LineAlignment = StringAlignment.Center;
        using (Font font = new Font(Font.FontFamily, 45, FontStyle.Bold))
        {
            Font myFont = e.Cache.GetFont(font, FontStyle.Bold);

            Brush myBrush = e.Cache.GetSolidBrush(Color.FromArgb(120, Color.Red));
            Rectangle r = new Rectangle(500, 0, 800, 600);
            e.Cache.DrawVString("READ ONLY", myFont, myBrush, r, sf, -45);
        }
}
See Also