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

Disable default context menu for RadGridView

3 Answers 547 Views
ContextMenu
This is a migrated thread and some comments may be shown as answers.
Jeff Fillegar
Top achievements
Rank 1
Jeff Fillegar asked on 16 Nov 2009, 08:29 PM
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

3 Answers, 1 is accepted

Sort by
0
Svett
Telerik team
answered on 18 Nov 2009, 01:47 PM
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.
0
Michael
Top achievements
Rank 1
answered on 08 Apr 2019, 08:55 PM
I know this post is 9 years old, but you say to set Cancel to "false", but the code shows true.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 11 Apr 2019, 10:59 AM
Hello, Michael,    

I believe this is a typo. If you want to prevent the default context menu from showing it is necessary to be canceled by setting the ContextMenuOpeningEventArgs.Cancel property to true as it was demonstrated in Svetlin's reply.

In case you need to customize the default menu, you can refer to the following help article: https://docs.telerik.com/devtools/winforms/controls/gridview/context-menus/modifying-the-default-context-menu

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
ContextMenu
Asked by
Jeff Fillegar
Top achievements
Rank 1
Answers by
Svett
Telerik team
Michael
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or