Embedding arbitrary item in RadMenuStrip

Article Info

Rating: 3

 

Article information

Article relates to

r.a.d menustrip for WinForms

Created by

Tsvetan Raikov, Telerik

Last modified

 February 9, 2007

Last modified by

Tsvetan Raikov, Telerik


HOW-TO
Embed arbitrary item in RadMenuStrip

SOLUTION

In r.a.d menustrip you can embed any custom RadElement. To do this follow the steps below:

  1. Create instances of RadMenuContentItem and your custom element (in this case RadTextBoxElement):
     
    RadMenuContentItem contentItem = new RadMenuContentItem();  
    RadTextBoxElement textBoxElement = new RadTextBoxElement(); 

     
  2. Set the AutoSizeMode property to WrapAroundChildren. The MaxSize property must be set to some restrictive value:

    textBoxElement.AutoSizeMode =  
        Telerik.WinControls.RadAutoSizeMode.WrapAroundChildren; 
    textBoxElement.MaxSize = new Size(150, 19); 

     
  3. Assign  the ContentElement  property  with your custom element and add the content item to menu items list:

    contentItem.ContentElement = textBoxElement; 
    RadMenuItem1.Items.Add(contentItem); 

Comments

If you'd like to comment on this KB article, please, send us a Support Ticket.
Thank you!

Please Sign In to rate this article.