windowsforms-devexpress-dot-xtrarichedit-dot-richeditcontrol-fa069540.md
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
public event RichEditViewCustomDrawEventHandler CustomDrawActiveView
Public Event CustomDrawActiveView As RichEditViewCustomDrawEventHandler
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. |
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.
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);
}
}
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