RadTextBoxControl localize context menu

4 posts, 1 answers
  1. Maik
    Maik avatar
    4 posts
    Member since:
    May 2013

    Posted 26 Apr Link to this post

    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!

  2. Answer
    Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3451 posts

    Posted 26 Apr Link to this post

    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.
  3. Maik
    Maik avatar
    4 posts
    Member since:
    May 2013

    Posted 26 Apr in reply to Dess | Tech Support Engineer, Sr. Link to this post

    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

  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3451 posts

    Posted 26 Apr Link to this post

    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.
Back to Top