XRControl.Draw Event

Occurs when an XRControl object is drawn or redrawn in a report's Print Preview.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v19.2.dll


public virtual event DrawEventHandler Draw
Public Overridable Event Draw As DrawEventHandler

Event Data

The Draw event handler receives an argument of the DrawEventArgs type. The following properties provide information specific to this event.

Property Description
Bounds Gets a rectangle object specifying the height, width and location of the control.
Brick Gets a visual brick that represents this control's contents on a report page.
UniGraphics Provides access to an object that is used to draw report components.


Note that although the Draw event can be useful in many cases, when it is necessary to create a customized view of a control, we do not recommend using it. The reason is that customization, which is done in the Draw event's handler, can't be correctly exported to different formats (e.g. HTML, MHT, RTF, etc.). The better approach is to create a custom report control, which is correctly printed and exported because it consists of Printing System bricks. To learn more on how to create a custom report control, refer to the Creating a Custom Progress Bar Control tutorial in this documentation.


The following example demonstrates how to use the XRControl.Draw event. The handler method below draws a red ellipse in the rectangle occupied by the XRControl object.

using System.Drawing;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
// ...

private void xrControl1_Draw(object sender, DrawEventArgs e) {
    // Get a rectangle occupied by a control.
    Rectangle rect = Rectangle.Truncate(e.Bounds);

    if(e.UniGraphics is GdiGraphics) {
        // Obtain a Graphics object.
        GdiGraphics graph = (GdiGraphics)e.UniGraphics;

        // Fill the interior of the ellipse defined
        // by the rectangle with a Red color.
        graph.Graphics.FillEllipse(Brushes.Red, rect);
See Also