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

Connecting a RadContextMenu to a RadGridView programmatically

2 Answers 213 Views
ContextMenu
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 13 Dec 2012, 09:32 PM
How would I go about adding a RadContextMenu to a RadGridView programmatically? I am building the RadGridView completely in code at runtime, and don't have a predefined XAML component.

The RadGridView only seems to have a ContextMenu that can be set, but I can't hook a RadContextMenu to the ContextMenu property.

Any advice? I need this so I can have the row that is right-clicked selected, and I can look at the current cell so that I can have specific menu items added to the context menu.

2 Answers, 1 is accepted

Sort by
0
Rosen Vladimirov
Telerik team
answered on 14 Dec 2012, 07:39 AM
Hi Mike,

Please check this article where you will find useful information how to set RadContextMenu. In your case you should use something like this:
RadGridView grid = new RadGridView();
RadContextMenu contextMenu = new RadContextMenu();
contextMenu.Items.Add (new RadMenuItem { Header = "Item 1" } );
RadContextMenu.SetContextMenu(grid, contextMenu);

Hopefully this helps.

Greetings,
Rosen Vladimirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Oscar
Top achievements
Rank 1
answered on 12 Jul 2016, 06:02 PM

Hi Mike,

Thanks for your help the article was helpful.

I have a question:

I'd like to know how can I add the RadContextMenu only in a specific Column from my RadGridView programmatically, there a way to do that?

Tags
ContextMenu
Asked by
Mike
Top achievements
Rank 1
Answers by
Rosen Vladimirov
Telerik team
Oscar
Top achievements
Rank 1
Share this question
or