Add Winform Usercontrol as hosteditem in CommandBar

4 posts, 0 answers
  1. Yip Yew Kwong
    Yip Yew Kwong avatar
    14 posts
    Member since:
    May 2010

    Posted 19 Jan 2012 Link to this post

    Hi,

    Is it possbile to add usercontrol as hosted item in the Commandbar?

    Thanks
  2. Yip Yew Kwong
    Yip Yew Kwong avatar
    14 posts
    Member since:
    May 2010

    Posted 20 Jan 2012 Link to this post

    What I want to archieve is to nest a 3rd party toolbar in the commandbar strip. Can anyone advice whether this is possbile? Thanks.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 24 Jan 2012 Link to this post

    Hi Yip,

    Thank you for this question.

    You should first wrap the user control inside RadHostItem and after that you will be able to add it into CommandBarHostItem. Please consider the following code snippet:

    UserControl myControl= new UserControl ();
    RadHostItem hostedButton = new RadHostItem(myControl);
    hostedButton.MinSize = new Size(60, 20);//this line set the size 
    this.commandBarHostItem1.HostedItem = hostedButton;

    I hope this helps.Don't hesitate to contact us if you have other questions.

    Kind regards,

    Peter
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

  5. Yip Yew Kwong
    Yip Yew Kwong avatar
    14 posts
    Member since:
    May 2010

    Posted 25 Jan 2012 Link to this post

    Hi,
    Thanks for the response. Your solution works. The only change I have made is
    hostedButton.MinSize = myControl.Size;
    The hostedButton will be automatically assigned the size of usercontrol. 
Back to Top