Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
140
How do I tell which button in ChartDataClicked ?
posted

Hi.

How can I tell which button was clicked in the ChartDataClicked event handler?

I get a ChartDataEventArgs object but this doesnt seem to tell me which button was used. Is there any way to tell this?

I am using NetAdvantage 8.1

Tks

 

Dan

  • 7305
    Verified Answer
    posted

    If you deffinitely need to handle ChartDataClick event, then what you can do is create a global variable, set it the the value that you obtained from ChartDataClicked event, and then use MouseDawn event to obtain button (left/right) such as:

           ultraChart1.ChartDataClicked += new ChartDataClickedEventHandler(ultraChart1_ChartDataClicked);
           ultraChart1.MouseDown += new MouseEventHandler(ultraChart1_MouseDown);       

           private double dVal;
           private bool sw = false;

           void ultraChart1_ChartDataClicked(object sender, ChartDataEventArgs e)
           {
                dVal = e.DataValue;
                sw = true;
           }

           void ultraChart1_MouseDown(object sender, MouseEventArgs e)
           {
                if (sw)
                {
                    MessageBox.Show(e.Button.ToString() + ", " + dVal.ToString());
                }
                sw = false;
           }