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

Add Winform Usercontrol as hosteditem in CommandBar

3 Answers 206 Views
CommandBar
This is a migrated thread and some comments may be shown as answers.
Yip Yew Kwong
Top achievements
Rank 1
Yip Yew Kwong asked on 19 Jan 2012, 10:49 AM
Hi,

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

Thanks

3 Answers, 1 is accepted

Sort by
0
Yip Yew Kwong
Top achievements
Rank 1
answered on 20 Jan 2012, 09:30 AM
What I want to archieve is to nest a 3rd party toolbar in the commandbar strip. Can anyone advice whether this is possbile? Thanks.
0
Peter
Telerik team
answered on 24 Jan 2012, 09:41 AM
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).

0
Yip Yew Kwong
Top achievements
Rank 1
answered on 26 Jan 2012, 03:05 AM
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. 
Tags
CommandBar
Asked by
Yip Yew Kwong
Top achievements
Rank 1
Answers by
Yip Yew Kwong
Top achievements
Rank 1
Peter
Telerik team
Share this question
or