This documentation is archived and is not being maintained.

Chart.MouseDown Event

Occurs when a mouse button is pressed when the pointer is over a Chart control.

Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel (in microsoft.office.tools.excel.dll)

public event ChartEvents_MouseDownEventHandler MouseDown

The following code example creates a Chart with a handler for the MouseDown event that displays the coordinates of the mouse pointer in cell D14 when the mouse button is pressed while the pointer is over the chart.

private void DisplayMouseDown()
{
    this.Range["A1", "A5"].Value2 = 22;
    this.Range["B1", "B5"].Value2 = 55;

    Microsoft.Office.Tools.Excel.Chart chart1 =
        this.Controls.AddChart(this.Range["D2", "H12"], 
        "chart1");
    chart1.SetSourceData(this.Range["A1", "B5"], 
        Excel.XlRowCol.xlColumns);
    chart1.ChartType = Excel.XlChartType.xl3DColumn;

    chart1.MouseDown +=
        new Excel.ChartEvents_MouseDownEventHandler(
        chart1_MouseDown);
}

void chart1_MouseDown(int Button, int Shift, int x, int y)
{
    this.Range["D14", missing].Value2 = "The chart was clicked at" +
        " coordinates " + x.ToString() + ", " + y.ToString();
}

Show: