Skip to main content

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.2.dll

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