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

Disable some context menus and menu items

1 Answer 79 Views
RichTextEditor
This is a migrated thread and some comments may be shown as answers.
Mihajlo
Top achievements
Rank 1
Mihajlo asked on 04 Oct 2018, 04:09 PM

How do I disable context menus "EditHeader" and "EditFooter", so that they don't show up?

How do I remove (rather than disable) context menu item "Hyperlink..."?

1 Answer, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 05 Oct 2018, 10:03 AM
Hello, Mihajlo, 

The following code snippet demonstrates how you can control which items to be visible in the context menu that RadRichTextEditor shows and hide the redundant ones:

public RadForm1()
{
    InitializeComponent();
 
    Telerik.WinControls.RichTextEditor.UI.ContextMenu menu =
        this.radRichTextEditor1.RichTextBoxElement.ContextMenu as Telerik.WinControls.RichTextEditor.UI.ContextMenu;
    menu.ContentBuilder = new CustomContextMenuContentBuilder();
      
}
 
public class CustomContextMenuContentBuilder : Telerik.WinForms.RichTextEditor.RichTextBoxUI.Menus.ContextMenuContentBuilder
{
    public override Telerik.WinForms.RichTextEditor.RichTextBoxUI.Menus.ContextMenuGroupCollection Construct()
    {
        Telerik.WinForms.RichTextEditor.RichTextBoxUI.Menus.ContextMenuGroupCollection collection = base.Construct();
 
        foreach (var item in collection)
        {
            Telerik.WinForms.RichTextEditor.RichTextBoxUI.Menus.ContextMenuGroup group = item as Telerik.WinForms.RichTextEditor.RichTextBoxUI.Menus.ContextMenuGroup;
            if (group!=null)
            {
                foreach (var menuItem in group)
                {
                    if (menuItem.Text.Contains("Hyperlink") )
                    {
                        menuItem.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
                    }
                }
            }
        }
        return collection;
    }
 
    private void menuItem_Click(object sender, EventArgs e)
    {
        Console.WriteLine("Clicked");
    }
}

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
RichTextEditor
Asked by
Mihajlo
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or