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.v20.1.dll

Declaration

public event RichEditViewCustomDrawEventHandler CustomDrawActiveView
Public Event CustomDrawActiveView As RichEditViewCustomDrawEventHandler

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 illustrates handling 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;
        Font myFont = e.Cache.GetFont(new Font(Font.FontFamily, 45, FontStyle.Bold), 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