RadContextMenu not painting properly

2 posts, 0 answers
  1. James
    James avatar
    4 posts
    Member since:
    Jul 2012

    Posted 22 Jun 2012 Link to this post

    Before I log this as an issues, I want to ensure that what I am doing is correct.  I am using the RadTreeView with 3 levels of node and I am dynmaic assigning context menus based on the level.

    private void RadTreeView1_SelectedNodeChanged(object sender, RadTreeViewEventArgs e)
        if (e.Node.Level == 0) 
                     e.Node.ContextMenu =ContextMenu1 ; 
         else if (e.Node.Level == 1) 
                     e.Node.ContextMenu =ContextMenu2; 
         else (e.Node.Level == 2) 
                    e.Node.ContextMenu =ContextMenu3 ; 

    When I right click on the level 2, my context menu works perfect.  When I right click on any other level, I get a single line of pixels which I believe is my menu.  Am I doing the correctly?


  2. Svett
    Svett avatar
    728 posts

    Posted 26 Jun 2012 Link to this post

    Hello James,

    We have addressed the question in the support ticket that you have opened about the same topic. I am pasting the answer here in case there are other people interested in the answer:

    This line of pixels would happen if your context menu is empty. Could you please make sure that you are filling the menu with items? 

    Instead of the approach that you are currently following, I would recommend handling the ContextMenuOpening event where you can have greater control over the behavior of the context menus. The Node property of the event arguments will return the node for which the context menu is clicked, so you again will be able to achieve your scenario. 

    Please note that in order to make the ContextMenuOpening event fire, you need to set the AllowDefaultContext menu to true:

    this.radTreeView1.AllowDefaultContextMenu = true;

    And this could be the ContextMenuOpening implementation: 
    void radTreeView1_ContextMenuOpening(object sender, TreeViewContextMenuOpeningEventArgs e)
        if (e.Node.Level == 1)
            e.Menu.Items.Add(new RadMenuItem("My Menu Item"));

    A bit off topic, I would kindly ask you to avoid double posting one and the same question as this may slow down our response and may lead to confustion. In case you require a quick answer according to your license, please directly open a new support ticket. Thank you for your understanding. Greetings,
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Back to Top