Textbox and ContextMenuStrip

4 posts, 1 answers
  1. Kim Johansen
    Kim  Johansen avatar
    4 posts
    Member since:
    Oct 2009

    Posted 13 Jan 2010 Link to this post

    Hi

    If I attach a ContextMenuStrip to a RadTextBox is not showing, but if I on the same form add the same ContextMenuStrip to a normal Textbox is shows. What have I done wrong ?

    Best Regards
    Kim Johansen
  2. Answer
    Nikolay
    Admin
    Nikolay avatar
    1804 posts

    Posted 14 Jan 2010 Link to this post

    Hi Kim Johansen,

    Thank you for the question.

    RadTextBox hosts the Microsoft TextBox control for its textbox part. When you set the ContextMenuStrip property of RadTextBox, the contextmenu is shown when you right-click on the RadElements of the RadTextBox (which are available close to the border). In order to get the custom contextmenu in the textbox part as well, please set it explicitly to the hosted TextBox:
    ((TextBox)this.radTextBox1.TextBoxElement.TextBoxItem.HostedControl).ContextMenuStrip = this.contextMenuStrip1;

    You can also use our RadContextMenu in RadTextBox. Please refer to the following help article for additional information: Assign RadContextMenu to Telerik and non-Telerik controls.

    If you have additional questions, feel free to contact me.

    Kind regards,
    Nikolay
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Kim Johansen
    Kim  Johansen avatar
    4 posts
    Member since:
    Oct 2009

    Posted 14 Jan 2010 Link to this post

    Hi Nikolay

    Thanks for your answer and that works.

    But I don't understand why its not working if I set the textbox contextmenustrip property to my own contextmenustrip in design mode. Why should I do it programly ? Is it a bug in your component or do I have misunderstand something ?

    Best regards
    Kim Johansen



  5. Nikolay
    Admin
    Nikolay avatar
    1804 posts

    Posted 14 Jan 2010 Link to this post

    Hello Kim Johansen,

    Setting the RadTextBox.ContextMenuStrip property at design-time does automatically set the ContextMenuStrip property of the internal TextBox control. The automatic synchronization between RadTextBox and the internal TextBox is currently not supported.

    This case is described in our help documentaton.

    If you have additional questions, feel free to contact me.

    Sincerely yours,
    Nikolay
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top