Back to Devexpress

How to: Provide a Custom Cursor for a Chart

windowsforms-8445-controls-and-libraries-chart-control-examples-end-user-interaction-how-to-provide-a-custom-cursor-for-a-chart.md

latest1.5 KB
Original Source

How to: Provide a Custom Cursor for a Chart

  • Nov 13, 2018

This example demonstrates how to substitute the Hand and Grab cursors shown when a chart’s area is being scrolled with a default system cursor.

To do this, handle the ChartControl.QueryCursor event, and use the QueryCursorEventArgs.Cursor and QueryCursorEventArgs.CursorType properties.

csharp
using System;
using System.Windows.Forms;
using DevExpress.XtraCharts;
// ...
private void chartControl1_QueryCursor(object sender, QueryCursorEventArgs e) {
    if (e.CursorType == CursorType.Hand || e.CursorType == CursorType.Grab) {
        e.Cursor = Cursors.Default;
    }
}
vb
Imports System
Imports System.Windows.Forms
Imports DevExpress.XtraCharts
' ...
Private Sub chartControl1_QueryCursor(ByVal sender As Object, ByVal e As QueryCursorEventArgs) Handles chartControl1.QueryCursor
    If e.CursorType = CursorType.Hand OrElse e.CursorType = CursorType.Grab Then
        e.Cursor = Cursors.Default
    End If
End Sub

The following images demonstrate how this works.

Default CursorCustom Cursor