How to collapse RadButtonElements of the QuickAccessToolBar

4 posts, 1 answers
  1. Andreas Karpinski
    Andreas Karpinski avatar
    8 posts
    Member since:
    Sep 2009

    Posted 07 Sep 2010 Link to this post

    Hi,

    in my RadRibbonBar are 4 RadButtonElements in the QuickAccessToolBar (radRibbonBar.QuickAccessToolBarItems).
    Now i want to collapse one or more Buttons at runtime. Therefor i've set the Visibility-Propertie of the RadButtonElement to Collapsed:

    radButtonElement.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
    Nothing happens.

    Than i try to refresh parts of, or the whole, the RibbonBar.
    At first i tried it with RadButtonElement.UpdateLayout(). - Same result, nothing happens.
    Next i've used the Refresh- and Update-Methode of the RibbonBar - still no results.
    And at last i've add a new RadButtonElement to the QuickAccessToolBarItems of RibbonBar in the hope that the RibboBar now refresh itself.

    I only want to hide one or more Buttons programmatically.
    Can you explain me, how to get it working?


    Regards



  2. Answer
    Peter
    Admin
    Peter avatar
    1148 posts

    Posted 09 Sep 2010 Link to this post

    Hi Andreas Karpinski,

    Thanks for writing.

    You cannot manage Button's Visibility state because the Quick Access toolbar uses this property internally to show and hide buttons. You should Remove and Add buttons elements in Quick Access Toolbar in order to show/ hide them. Please refer to code sniped below:

    //Hide button
    this.radRibbonBar1.QuickAccessToolBarItems.Remove(this.radButtonElement1);
    //Show button
    this.radRibbonBar1.QuickAccessToolBarItems.Add(this.radButtonElement1);

    I hope this helps.

    Kind regards,
    Peter
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Andreas Karpinski
    Andreas Karpinski avatar
    8 posts
    Member since:
    Sep 2009

    Posted 10 Sep 2010 Link to this post

    Oh, thanks for your answer.
    I also want to write this as my alternativ solution - to late ^^.
    Whatever. Here is my real post:

    As an alternativ solution, i delete the button (alternativ Hide) an create a new one (alternativ Show).

    I write the following Methode to make a hide/show.

    public void SetButtonVisibility ( bool hideButton )
    {
    // Get the Ribbonbar
    RadRibbonBar radRibbonBar = (RadRibbonBar)(this.Controls.Find("radRibbonBar", true)[0]);

    // Get the spezific Button with ID "bttTest"
    RadItem testButton = radRibbonBar.QuickAccessToolBarItems["bttTest"];

    // If we want to hold the button-order, we need to delete the buttons previously
    if (testButton != null)
           // if the button exist, we will delete him from the QuickAccessBar
           radRibbonBar.QuickAccessToolBarItems.Remove(testButton);

    // if the Parameter hideButton is set to FALSE, we will create(=show)  the Button
    // if hideButton is set to TRUE, the button is already deleted

    if ( ! hideButton )
    {
                    // Set generally Properties
                    RadButtonElement element = new RadButtonElement();
                    element.Class = "RibbonBarButtonElement";
                    element.MaxSize = new System.Drawing.Size(0, 18);
                    element.Padding = new System.Windows.Forms.Padding(2, 1, 2, 2);

                    // Set spezific Properties
                    element.Name = "bttTest";
                    element.Text = "Test";

                    // Add spezific Event/s
                    // element.Click += new EventHandler(bttTest_Click);

                   
                    // Add the Button to the QuickAccessBar
                    radRibbonBar.QuickAccessToolBarItems.Add(element);
    }
    }
  5. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 15 Sep 2010 Link to this post

    Hi Andreas,

    Thank you for sharing your solution.

    You can also use our approach - it completely covers this scenario.

    Do not hesitate to contact us if you have other questions.

    Regards,
    Peter
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top