The pick mechanism allows MouseEvents to be associated with chart nodes. The pick mechanism follows the .NET delegate pattern.

A PickEventHandler is added to a ChartNode, using the nodeís PickPerformed method and the delegate += syntax to define the method to be called when the event occurs.

A pick is fired by calling the method Chart.Pick in the top-level ChartNode. Normally this is done in response to a mouse click. Mouse clicks can be detected by adding a MouseEventHandler to the MouseDown property of the chartís container.


In this example, when a bar is clicked it toggles its color between blue and red.

A MouseEventHandler is added to the Panel, which calls method Chart.Pick.

The pick delegate is added to the chart node bar. This means that it is active for that node and its children but is not active for the axes and other nodes.

 (Download Code)


using System.Windows.Forms;

using System.Drawing;

using Imsl.Chart2D;


public class SamplePick : FrameChart


    private Chart chart;

    private double[] x = new double[]{0, 1, 2, 3};

    private double[] y = new double[]{4, 1, 2, 5};


    public SamplePick()


        chart = this.Chart;

        AxisXY axis = new AxisXY(chart);

        Bar bar = new Bar(axis, x, y);

        bar.BarType = Bar.BAR_TYPE_VERTICAL;

        bar.SetLabels(new string[]{"A","B","C", "D"});

        bar.FillColor = Color.Blue;


        // Add the event handler delegates

        bar.PickPerformed += new PickEventHandler(SamplePick_PickPerformed);

        this.Panel.MouseDown += new MouseEventHandler(SamplePick_MouseDown);



    private void SamplePick_MouseDown(object sender, MouseEventArgs e)





    private void SamplePick_PickPerformed(PickEventArgs param)


        ChartNode node = param.Node;

        int count = node.GetIntegerAttribute("pick.count", 0);


        node.SetAttribute("pick.count", (System.Object) (count));


        // Change the bar's color depending on the number of times

        // it has been picked.

        Color color = ((count % 2 == 0) ? Color.Blue : Color.Red);

        node.FillColor = color;




    public static void Main(string[] argv)


        System.Windows.Forms.Application.Run(new SamplePick());




Visual Numerics - Developers of IMSL and PV-WAVE
PHONE: 713.784.3131