Connecting a RadContextMenu to a RadGridView programmatically

3 posts, 0 answers
  1. Mike
    Mike avatar
    23 posts
    Member since:
    Jun 2012

    Posted 13 Dec 2012 Link to this post

    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. Rosen Vladimirov
    Rosen Vladimirov avatar
    640 posts

    Posted 14 Dec 2012 Link to this post

    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.

    Rosen Vladimirov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Oscar
    Oscar avatar
    1 posts
    Member since:
    Jul 2016

    Posted 12 Jul Link to this post

    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?

Back to Top