ChartControl.CustomPaint Event

Occurs after all the chart's visual elements have been drawn.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v20.1.UI.dll

Declaration

public event CustomPaintEventHandler CustomPaint
Public Event CustomPaint As CustomPaintEventHandler

Event Data

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

Property Description
Bounds Gets the bounds of a custom graphic object.
Graphics Gets the custom graphic object.

Remarks

Use the CustomPaint event, to draw custom graphics over your chart.

Cast the Event Args object to the DXCustomPaintEventArgs class and use its DXCustomPaintEventArgs.Cache property to draw custom content properly in the control surface correctly in the DirectX mode. Note that this property also allows you to draw custom content in the GDI+ mode.

For example, the XYDiagram2D.DiagramToPoint and RadarDiagram.DiagramToPoint methods allow you to draw custom content tied to existing chart elements (series, series points and so on) when you utilize them in the event handler.

IMPORTANT

Changes made by the event handler do not affect 3D charts.

Examples

This example demonstrates how to use the DXCustomPaintEventArgs class to display a custom image over the chart.

public partial class MainForm : XtraForm {
    static readonly Image logo = new Bitmap("../../Images/DXLogo.png");

    public MainForm() {
        InitializeComponent();

        chartControl.CustomPaint += this.OnChartCustomPaint;
    }

    private void OnChartCustomPaint(object sender, CustomPaintEventArgs e) {
        if (!(e is DXCustomPaintEventArgs dxArgs)) return;
        dxArgs.Cache.DrawImage(logo, new Point(10, 10));
    }
}
See Also