RadRichTextBox Context Menu customize - Remove Hyperlink Font Paragraph Menu items

2 Answers 29 Views
ContextMenu RichTextBox
Ramesh
Top achievements
Rank 1
Iron
Ramesh asked on 20 May 2021, 05:41 PM

Hello, we are using the RadRIchTextBoxes, in our WPF application in different Modules.

We are using it like a plain text box, but using the SpellCheck Feature to check the spelling of upper case. (   this.custNotesRichTextBox.SpellChecker.Settings.SpellCheckUppercaseWords = true;)

We use the context menu to get the spelling suggestions. But we do not want the user to use, Hyperlink, FONT, how do we disable this.

We wanted to see if we can disable in the main WPF application (where we add reference to the Telerik.Windows.Documents.Proofing.Dictionaries.En-US) than in each module. Because we feel customizing for each textbox would consume memory.

Please refer screenshot below.

 

 

 

2 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 21 May 2021, 10:33 AM

Hi Ramesh,

You can use the following approach for this: 

public MainWindow()
{
    InitializeComponent();
    var contextMenu = (Telerik.Windows.Controls.RichTextBoxUI.ContextMenu)this.radRichTextBox.ContextMenu;
    contextMenu.Showing += RichTextBox_ContextMenuShowing;
}
private void RichTextBox_ContextMenuShowing(object sender, Telerik.Windows.Controls.RichTextBoxUI.Menus.ContextMenuEventArgs e)
{
    for (int i = e.ContextMenuGroupCollection.Count  ; i > 1; i--)
    {
        e.ContextMenuGroupCollection.RemoveAt(1);
    }
     
}

Detailed information is available here: WPF RichTextBox | Context Menu

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Ramesh
Top achievements
Rank 1
Iron
commented on 21 May 2021, 08:03 PM

Hello Dimitar,

Thanks! It works perfectly!!

Regards,
Ramesh
Ramesh
Top achievements
Rank 1
Iron
commented on 27 May 2021, 09:11 PM

Hello Dimitar, How do I make the context Menu changes globally, meaning I have RichTextBox used in different modules in my WPF project. I don't want to write the above code in every place. I want the same context Menu behaviour across my all RichTextboxes. can we put it in App.xaml.cs. Please explain how we can get the instance there.
0
Dimitar
Telerik team
answered on 31 May 2021, 08:18 AM

Hi Ramesh,

What you can do is add the RadRichTextBox to user control, implement the additional functionality and then use the new user control in all places where this is required. 

Let me know if I can assist you further.

Regards,
Dimitar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
ContextMenu RichTextBox
Asked by
Ramesh
Top achievements
Rank 1
Iron
Answers by
Dimitar
Telerik team
Share this question
or