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

How to collapse RadButtonElements of the QuickAccessToolBar

3 Answers 134 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
Andreas Karpinski
Top achievements
Rank 1
Andreas Karpinski asked on 07 Sep 2010, 10:28 AM
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



3 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 09 Sep 2010, 05:41 PM
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
0
Andreas Karpinski
Top achievements
Rank 1
answered on 10 Sep 2010, 07:17 AM
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);
}
}
0
Peter
Telerik team
answered on 15 Sep 2010, 04:01 PM
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
Tags
RibbonBar
Asked by
Andreas Karpinski
Top achievements
Rank 1
Answers by
Peter
Telerik team
Andreas Karpinski
Top achievements
Rank 1
Share this question
or