Disable default context menu for RadGridView

2 posts, 0 answers
  1. Jeff Fillegar
    Jeff Fillegar avatar
    1 posts
    Member since:
    Jul 2009

    Posted 16 Nov 2009 Link to this post

    How can you disable the default context menu for the RadGridView?  We already have our right-click context menu control added to the form and have it working with the RadGridView; however, the default context menu is displayed behind it.  I would imagine it is very easy to disable I just haven't found out how to.

    Thanks in advance.
    Jeff
  2. Svett
    Admin
    Svett avatar
    728 posts

    Posted 18 Nov 2009 Link to this post

    Hi Jeff Fillegar,

    Thank you for contacting us and for your question.

    In order to replace the default RadGridView context menu with yours, you should subscribe to the ContextMenuOpening event, where the Cancel property of ContextMenuOpeningEventArgs should be set to false.

    public Form()
    {
      this.radGridView.ContextMenuOpening += new ContextMenuOpeningEventHandler(radGridView_ContextMenuOpening);
    }
     
    private void radGridView_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
    {
        e.Cancel = true;
    }

    private void Form_Load(object sender, EventArgs e)
    {
       this._menu = new ContextMenu();
       this._menu.MenuItems.Add("Item 1");
       this._menu.MenuItems.Add("Item 2");
       this.radGridView1.ContextMenu = this._menu;
    }

    If you have other questions, feel free to contact us again.

    Best wishes,
    Svett
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top