CommandBarStripElement Items

5 posts, 1 answers
  1. di
    di avatar
    7 posts
    Member since:
    Feb 2011

    Posted 23 Apr 2015 Link to this post

    Is there the way to fix the position of some items in CommandBarStripElement so those items are always visible and could not be moved to the overflow.

    I guess it is pointless to override OnItemOverflowed as it is already too late, the item already moved to overflow menu. Isn't it?

     

    Thanks.

     

  2. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 24 Apr 2015 Link to this post

    Hello Di,

    Thank you for writing.

    When you shrink the RadCommandBar the items in the CommandBarStripElement get overflowed. Hence, they are placed in the overflow menu. There is not automatic way to prevent a certain item from hiding. However,you can subscribe to the CommandBarStripElement.ItemOutOfOverflow event and insert the hidden item at a previous position in the CommandBarStripElement.Items collection. Thus, the item will be visible. Here is an example how to make the CommandBarDropDownList visible by inserting it at the first position:
    private void commandBarStripElement1_ItemOverflowed(object sender, EventArgs e)
    {
        CommandBarDropDownList ddl = sender as CommandBarDropDownList;
        if (ddl!=null)
        {
            this.commandBarStripElement1.Items.Remove(ddl);
            this.commandBarStripElement1.Items.Insert(0, ddl);
        }
    }

    I hope this information helps. Should you have further questions, I would be glad to help.
     
    Regards,
    Dess
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. di
    di avatar
    7 posts
    Member since:
    Feb 2011

    Posted 28 Apr 2015 in reply to Dess Link to this post

    Hi Dess,

    Thanks for your reply, but that solution doesn't fix the issue I am trying to avoid.

    I've got two strip elements on the same row and when I start window resize the left strip elements starts hiding buttons first.

    I identified the feature which causes this scenario. If the command bar items displayed in runtime exactly as they appeared in design time it all worked fine - the right strip shrinks, then left one continue. But when I change the button text to longer one the left strip starts shrinking first.

    Please check the attached RadCommandBarTest sample.(Please rename the attached file to zip)

    Please run the project as it is first. Then in Form1.cs OnLoad method uncomment line 49

    //radCommandBarToggleButtonItem9.Text = "Modified Button 2";

    and run the sample again.

    The bottom line - I want to prevent the left-hand strip element from shrinking before the right one.

     

    Many Thanks.

  5. Answer
    Dess
    Admin
    Dess avatar
    1609 posts

    Posted 30 Apr 2015 Link to this post

    Hello Di,

    Thank you for writing back.

    When you construct the items in RadCommandBar at design time, the CommandBarStripElement calculates its DesiredLocation considering the items' Text. If you change the text of a certain item from the left strip element to a longer string, the DesiredLocation for the second strip will remain with the previous X value. That is why when you start shrinking the form the second strip element will try to get to its DesiredLocation. The possible solution that I can suggest is to adjust the DesiredLocation of the right strip element after changing the text.
     
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
     
        radCommandBarToggleButtonItem9.Text = "Modified Button 2";
        commandBarStripElement2.DesiredLocation = commandBarStripElement2.Location;
        this.radCommandBarLineElement1.Strips.Remove(this.commandBarStripElement2);
        this.radCommandBarLineElement2.Strips.Add(this.commandBarStripElement2);
    }

    I hope this information helps. If you have any additional questions, please let me know.
     
    Regards,
    Dess
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  6. di
    di avatar
    7 posts
    Member since:
    Feb 2011

    Posted 03 May 2015 in reply to Dess Link to this post

    Dess,

    That solution works perfectly fine.

    Thanks a lot.

Back to Top
UI for WinForms is Visual Studio 2017 Ready