ChartView ContextMenuOpening Event

2 posts, 0 answers
  1. Tarek
    Tarek avatar
    1 posts
    Member since:
    Sep 2014

    Posted 14 Sep 2014 Link to this post

    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.



  2. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 17 Sep 2014 Link to this post

    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.
     
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top