Back to Devexpress

RichEditControl.CustomDrawActiveView Event

windowsforms-devexpress-dot-xtrarichedit-dot-richeditcontrol-fa069540.md

latest3.4 KB
Original Source

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

NuGet Package : DevExpress.Win.RichEdit

Declaration

csharp
public event RichEditViewCustomDrawEventHandler CustomDrawActiveView
vb
Public Event CustomDrawActiveView As RichEditViewCustomDrawEventHandler

Event Data

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

PropertyDescription
CacheGets 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.

csharp
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);
        }
}
vb
Private Sub richEditControl_CustomDrawActiveView(ByVal sender As Object, _
ByVal e As RichEditViewCustomDrawEventArgs) _ 
Handles richEditControl.CustomDrawActiveView
    Using sf As StringFormat = New StringFormat()
        sf.Alignment = StringAlignment.Center
        sf.LineAlignment = StringAlignment.Center
        Using font As New Font(Font.FontFamily, 45, FontStyle.Bold)
            Dim myFont As Font = e.Cache.GetFont(font, FontStyle.Bold)

            Dim myBrush As Brush = e.Cache.GetSolidBrush(Color.FromArgb(120, Color.Red))
            Dim r As New Rectangle(500, 0, 800, 600)
            e.Cache.DrawVString("READ ONLY", myFont, myBrush, r, sf, -45)
        End Using
    End Using
End Sub

See Also

CustomMarkDraw

RichEditControl Class

RichEditControl Members

DevExpress.XtraRichEdit Namespace