CommandBar Samples

5 posts, 2 answers
  1. Joe Sugden
    Joe Sugden avatar
    52 posts
    Member since:
    Feb 2010

    Posted 19 Nov 2010 Link to this post

    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
  2. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 20 Nov 2010 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 20 Nov 2010 Link to this post

    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
  5. Joe Sugden
    Joe Sugden avatar
    52 posts
    Member since:
    Feb 2010

    Posted 22 Nov 2010 Link to this post

    Thank you for your help.  Your snippets accurately answered my question.

    Joe
  6. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 22 Nov 2010 Link to this post

    You're welcome Joe. Glad to have been able to help
    Richard
Back to Top
UI for WinForms is Visual Studio 2017 Ready