Skip to main content
A newer version of this page is available. .

DiagramControl.CustomDrawBackground Event

Occurs before the Canvas background is rendered.

Namespace: DevExpress.XtraDiagram

Assembly: DevExpress.XtraDiagram.v19.1.dll

Declaration

[DiagramCategory(DiagramCategory.DiagramPaint)]
public event EventHandler<CustomDrawBackgroundEventArgs> CustomDrawBackground

Event Data

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

Property Description
ContentBounds Gets the rectangle which encompasses the background area excluding margins.
Context Gets whether the item is to be drawn on the canvas, toolbox, in the print or export output or as the drag preview.
Graphics Returns an object that provides painting facilities.
PagesInfo Gets the list of diagram pages.
PrintBounds Gets the rectangle which encompasses the total background area when printing the diagram.
PrintClientBounds Gets the rectangle which encompasses the background area excluding margins when printing the diagram.
PrintIndex Gets the zero-based index of the page that is currently being rendered when printing the diagram.
TotalBounds Gets the rectangle which encompasses the total background area.
ViewportBounds Gets the rectangle which encompasses the viewport area.

Remarks

Use the CustomDrawBackground event to draw a custom Canvas background.

The following code snippet illustrates how to set an image as the diagram background:


private void DiagramControl_CustomDrawBackground(object sender, CustomDrawBackgroundEventArgs e) {
    if (e.Context != DiagramDrawingContext.Print)
        e.Graphics.DrawImage(Image.FromFile("Images\\background.jpg"), e.TotalBounds);
}

Note

If the font’s Unit property is not set to GraphicsUnit.Pixel, the font size of the text drawn by the Graphics.DrawString method is scaled based on the DPI settings.

See Also