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

RadTextBoxControl localize context menu

3 Answers 140 Views
Documentation
This is a migrated thread and some comments may be shown as answers.
Maik
Top achievements
Rank 1
Maik asked on 26 Apr 2019, 08:55 AM

Hi everyone,

 

as a key-feature for the RadTextBoxControl a localizable context menu is mentioned. I now have to take advantage of this feature, but cannot find any example or hint, how to do.

Additionally it would be interesting to know, how to customize a context menu and keep the standard functions like 'copy', 'paste', etc.

 

Any suggestions or examples?

 

Thanks in advance!

3 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 26 Apr 2019, 10:37 AM
Hello, Maik,    

In order to customize the default context menu in RadTextBoxControl and add your own menu items but keep the default ones, you can simply handle the ContextMenuOpening event as follows:

this.radTextBoxControl1.ContextMenuOpening += radTextBoxControl1_ContextMenuOpening;
 
 
private void radTextBoxControl1_ContextMenuOpening(object sender, Telerik.WinControls.UI.TreeBoxContextMenuOpeningEventArgs e)
{
    RadMenuItem item = new RadMenuItem("My menu item");
    item.Click += item_Click;
    e.ContextMenu.Items.Add(item);
}
 
private void item_Click(object sender, EventArgs e)
{
}

As to the localization question, you need to create a derivative of the TextBoxControlLocalizationProvider and override its GetLocalizedString method to specify the respective string: 

public class CustomTextBoxControlLocalizationProvider : TextBoxControlLocalizationProvider
{
    public override string GetLocalizedString(string id)
    {
        switch (id)
        {
            case TextBoxControlStringId.ContextMenuCopy:
                return "&Copy";
            case TextBoxControlStringId.ContextMenuCut:
                return "Cu&t";
            case TextBoxControlStringId.ContextMenuPaste:
                return "&Paste";
            case TextBoxControlStringId.ContextMenuDelete:
                return "&Delete";
            case TextBoxControlStringId.ContextMenuSelectAll:
                return "&Select All";
        }
 
        return string.Empty;
    }
}

public RadForm1()
{
    TextBoxControlLocalizationProvider.CurrentProvider = new CustomTextBoxControlLocalizationProvider();
    InitializeComponent();
}

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

Regards,
Dess | Tech Support Engineer, Sr.
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.
0
Maik
Top achievements
Rank 1
answered on 26 Apr 2019, 11:37 AM

Hey Dess,

 

thanks for the fast response. That was exactly what I was looking for.

Is this localization thing described in the documentation and I just did not find it?

https://docs.telerik.com/devtools/winforms/controls/editors/textboxcontrol/textboxcontrol

Or is there a more detailed documentation available?

 

Best regards

Maik

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 26 Apr 2019, 11:50 AM
Hello, Maik,    

I am glad that the suggested solution was suitable for your case.

The localization part of the solution is not included in the current documentation. However, it is really helpful to be included. We will do our best to update the online documentation with the next upload of the documentation.

Should you have further questions please let me know.

Regards,
Dess | Tech Support Engineer, Sr.
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
Documentation
Asked by
Maik
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Maik
Top achievements
Rank 1
Share this question
or