Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Determine whether an Axis Title is Being Hovered by the Mouse Pointer

This example demonstrates how you can determine whether an axis title is being hovered by the mouse pointer, and if so, display its type (AxisTitleX or AxisTitleY) in a tooltip.

using DevExpress.XtraCharts;
using System;
using System.Windows.Forms;

namespace AxisTitleHitTestSample {
    public partial class SampleForm : Form {
        public SampleForm() {
            InitializeComponent();
        }

        private void OnMouseMove(object sender, MouseEventArgs e) {
            ChartHitInfo hitInfo = chart.CalcHitInfo(e.X, e.Y);
            if (hitInfo.AxisTitle != null)
                tooltipController.ShowHint(
                    String.Format(
                        "The pointer is over the {0} object.", 
                        hitInfo.AxisTitle.GetType().ToString()
                    )
                );
            else
                tooltipController.HideHint();
        }
    }
}

The result is shown in the following image.

AxisTitleHitText

See Also