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

ChartControl.CustomPaint Event

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

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v18.2.UI.dll

Declaration

public event CustomPaintEventHandler CustomPaint

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.

Example

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));
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomPaint event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also