This is a migrated thread and some comments may be shown as answers.

ChartView ContextMenuOpening Event

1 Answer 117 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Tarek
Top achievements
Rank 1
Tarek asked on 14 Sep 2014, 05:52 AM
Hi,
I'm trying to handle this event, but I'm getting this error:
"'ContextMenuOpening' is not an event of 'Telerik.WinControls.UI.RadChartView'"
Note: I'm using RadControls for WinForms Q2 2012.



1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 17 Sep 2014, 11:23 AM
Hi Tarek,

Thank you for writing.

This event was introduced in Q2 2013 (version 2013.2.612) and cannot be used in versions before this one.

To replace the default context menu in your version you should create a custom ChartDataPointElementController class:
public class MyChartDataPointElementController : ChartDataPointElementController
{
    RadContextMenu radContextMenu1;
 
    protected RadContextMenu CreateContextMenu()
    {
        RadContextMenu Menu1 = new RadContextMenu();
        Menu1.Items.Add(new RadMenuItem("Item 1"));
        return Menu1;
    }
 
    protected override ActionResult OnMouseDown(MouseEventArgs e)
    {
        if (e.Button == System.Windows.Forms.MouseButtons.Right)
        {
            if (radContextMenu1 == null)
            {
                radContextMenu1 = CreateContextMenu();
            }
            radContextMenu1.Show(Control.MousePosition);
            return Controller.Empty;
        }
        else
        {
            return base.OnMouseDown(e);
        }
    }
}

The default controller can be replaced as follows:
void Form1_Load(object sender, EventArgs e)
{
    radChartView1.Controllers.Clear();
    radChartView1.Controllers.Add(new MyChartDataPointElementController());
}

I hope this helps.

Regards,
Dimitar
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
ChartView
Asked by
Tarek
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or