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

CommandBar Samples

4 Answers 264 Views
This is a migrated thread and some comments may be shown as answers.
Joe Sugden
Top achievements
Rank 1
Joe Sugden asked on 19 Nov 2010, 04:34 PM
How would I use "Text Only" buttons?

Any Examples using the CommandHostItem would be great.  The help talks about the HostedElement Property, but I don't see it in the designer properties window.  Can we really host any RadControl?

Thanks

4 Answers, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 20 Nov 2010, 10:41 AM
Hello Joe,

Having looked more closely at the CommandBarButton, in my view there has been an ommision.

The CommandBarButton has all the normal properties of a RadButton or other items that allow an Image and Text to be set. For example, you can set a TextImageRelation etc.. But, in a RadButton you can normally set a DisplayStyle which tells the control if it should render as Text, Image or Both. the DisplayStyle is not part of the CommandBarButton and I think it should be there. this link indicates text and image can be combined.

If you want a text only button there is a simple way around it, which also answers your second question on using a host item.

You can add a host item in the same way as you add other items to the Command Bar, but the host item is just a placeholder, ready for you to add a RadElement to it. So, to add a RadButtonElement with just text on to the RadCommandBar, then you can do the following

Dim button As New RadButton()
button.Text = "My Button"
button.DisplayStyle = DisplayStyle.Text
Me.CommandBarHostItem1.HostedItem = button.ButtonElement

I hope this helps, but let me know if you need more information
Richard
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 20 Nov 2010, 05:37 PM
Hello Joe,

I don't think you've reviewed this yet, which I am thankful for as I have given you some incorrect information.
The DisplayStyle property is the normal property that is used to set the text / Image style of a RadButton and most other items that contain text and image, but in the case of the new RadCommandBar you need to set a new property called DrawText

So, to have a text only button you would specify the following:
Me.CommandBarButton1.Text = "My Button Text"
Me.CommandBarButton1.DrawText = True
Me.CommandBarButton1.Image = Nothing

I hope this, together with my previous sample of adding a HostedItem has helped, but do let me know if you need more information. And apologies for the previous incorrect information.

regards,
Richard
0
Joe Sugden
Top achievements
Rank 1
answered on 22 Nov 2010, 06:59 PM
Thank you for your help.  Your snippets accurately answered my question.

Joe
0
Richard Slade
Top achievements
Rank 2
answered on 22 Nov 2010, 08:31 PM
You're welcome Joe. Glad to have been able to help
Richard
Asked by
Joe Sugden
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Joe Sugden
Top achievements
Rank 1
Share this question
or