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

ContextMenu

3 Answers 201 Views
ContextMenu
This is a migrated thread and some comments may be shown as answers.
Ching-Yen
Top achievements
Rank 1
Ching-Yen asked on 24 Mar 2008, 05:34 PM
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.

3 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 26 Mar 2008, 01:46 PM
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
0
Tamás
Top achievements
Rank 1
answered on 05 Aug 2008, 08:06 AM
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
0
Martin Vasilev
Telerik team
answered on 07 Aug 2008, 02:21 PM
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.
Tags
ContextMenu
Asked by
Ching-Yen
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Tamás
Top achievements
Rank 1
Martin Vasilev
Telerik team
Share this question
or