ContextMenu

4 posts, 0 answers
  1. Ching-Yen
    Ching-Yen avatar
    65 posts
    Member since:
    Nov 2007

    Posted 24 Mar 2008 Link to this post

    Hi,

    in the RadDropDownMenu, I found there is a place call ContextMenu. May I know how can I make use of them?

    I already have some code done in the ContextMenu. Is there any possible way to bind it to the newly created RadDropDownMenu?

    Please advice.
  2. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 26 Mar 2008 Link to this post

    Hello Ching-Yen,

    It is not possible to bind your ContextMenu to RadDropDownMenu. The reason for RadDropDownMenu to have ContextMenu property is because RadDropDownMenu inherits from Control which has the same property. In addition, please note that the ContextMenu property sets instances only of type ContextMenu, so you should use RadDropDownMenu in a different approach. You should subscribe to the MouseDown event, and if the right mouse button is clicked, create and show RadDropDownMenu:
     
    private void btnRadDDMenu_MouseDown(object sender, MouseEventArgs e)  
    {  
        if (e.Button == MouseButtons.Right)  
        {  
            RadDropDownMenu radMenu = new RadDropDownMenu();  
     
            RadMenuItem radMenuItem = new RadMenuItem();  
            radMenuItem.Text = "1";  
            radMenu.Items.Add(radMenuItem);  
     
            radMenuItem = new RadMenuItem();  
            radMenuItem.Text = "2";  
            radMenu.Items.Add(radMenuItem);  
     
            radMenuItem = new RadMenuItem();  
            radMenuItem.Text = "3";  
            radMenu.Items.Add(radMenuItem);  
     
            radMenu.Show(btnRadDDMenu, e.Location);  
        }  

    If you have additional questions, do not hesitate to contact me.

    Best wishes,
    Nikolay
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Tamás
    Tamás avatar
    6 posts
    Member since:
    Jul 2008

    Posted 05 Aug 2008 Link to this post

    Hello,

    I tried to use the code shown in the previous post. I wrote the code in the MouseDown event handler of a RadTextBox.

    My problem is that when I click in the text box with the right button, the default Windows context menu pops up with items like Cut, Paste, etc.. The RadDropDownMenu shows up only if I press the right button at the edge of the textbox.

    Is there a workaround? I just need a simple context menu for a textbox with items in it that I can click on.

    Thanks,
    Tamás
  5. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 07 Aug 2008 Link to this post

    Hello Tamás,

    Thank you for writing.

    The context menu is a feature of the hosted MS TextBox and it can be stopped from showing only with a workaround. The easiest way is to assign new empty ContextMenuStrip:
    this.radTextBox1.TextBoxElement.TextBoxItem.HostedControl.ContextMenuStrip =  
    new ContextMenuStrip(); 

    Other way to do the same you could find in following forum topic:
    http://www.telerik.com/community/forums/thread/b311D-bkageh.aspx

    I hope this helps. If you have other questions, do not hesitate to contact me again.

    Kind regards,
    Martin Vasilev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top