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

Strip Buttons not hiding when asked

5 Answers 84 Views
PageView
This is a migrated thread and some comments may be shown as answers.
Ian
Top achievements
Rank 1
Ian asked on 12 Feb 2013, 12:40 AM
Hi Guys

I'm trying to get the strip buttons to hide in my PageView and at the same time add in a RadButtonElement into the stripview button panel. The strip buttons do not want to hide and indeed won't hide when asked even when I don't add my RadButtonElement. I've tried the usual code from forum posts to no avail. I must be doing something wrong so any help would be great.

I use the following code. Note that I commented out another attempt to hide the buttons so you could see what I tried. The outcome of the code is in the attached screenshot.

private RadButtonElement btnAddTradingRule = new RadButtonElement();
 
    btnAddTradingRule.Image = Resources.Plus24;
    btnAddTradingRule.ImageAlignment = ContentAlignment.MiddleCenter;
    btnAddTradingRule.Click += BtnAddTradingRuleClick;
    btnAddTradingRule.MinSize = new Size(28, 28);
 
    rpvModelRule.RootElement.Children[0].Children[0].Children[1].Children.Insert(0, btnAddTradingRule);
 
    //foreach (var button in rpvModelRule.RootElement.Children[0].Children[0].Children[1].Children.Where(a => a.GetType() == typeof(RadPageViewStripButtonElement)))
    //{
    //    button.Visibility = ElementVisibility.Hidden;
    //}
 
 
    var radPageViewStripElement = rpvModelRule.ViewElement as RadPageViewStripElement;
    if (radPageViewStripElement != null)
    {
        radPageViewStripElement.ShowItemCloseButton = false;
        radPageViewStripElement.StripButtons = StripViewButtons.None;
 
    }

5 Answers, 1 is accepted

Sort by
0
Ian
Top achievements
Rank 1
answered on 12 Feb 2013, 12:48 AM
HI again

Sorry guys - my fault. They do disappear, but reappear again when I ask them to later in my code. A little refactoring required. :-)

Thanks anyway
Regards
Ian Carson
0
Stefan
Telerik team
answered on 12 Feb 2013, 07:29 AM
Hello lan,

I am glad to hear that everything is now OK on your end. Should you have any other questions, do not hesitate to contact us.

Kind regards,
Stefan
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
Ian
Top achievements
Rank 1
answered on 12 Feb 2013, 09:13 AM
Hi Guys

Apologies once again. I still need your help on this.

I want to be able to display a button at the right of the StripViewItemContainer of my PageView but without displaying any of the normal stripbuttonelements. I have been trying the above code in this thread but now can only get all buttons (including mine) to disappear or all buttons (including mine) to show.

Should I be using a stacklayoutPanel or some such?

Thanks in advance
Regards
Ian
0
Accepted
Stefan
Telerik team
answered on 15 Feb 2013, 08:00 AM
Hello lan,

Thank you for writing back.

What you can do is to first Collapse or Clear the existing buttons and then add yours. Here is a small example:
var radPageViewStripElement = radPageView1.ViewElement as RadPageViewStripElement;
if (radPageViewStripElement != null)
{
    radPageViewStripElement.ItemContainer.ButtonsPanel.Children.Clear();
 
    RadButtonElement btnAddTradingRule = new RadButtonElement();
    btnAddTradingRule.Image = Resources.folder_open;
    btnAddTradingRule.ImageAlignment = ContentAlignment.MiddleCenter;
    btnAddTradingRule.Click += btnAddTradingRule_Click;
    btnAddTradingRule.MinSize = new Size(28, 28);
 
    radPageViewStripElement.ItemContainer.ButtonsPanel.Children.Insert(0, btnAddTradingRule);
}

Let me know how this works for you.
 

Kind regards,
Stefan
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
Ian
Top achievements
Rank 1
answered on 15 Feb 2013, 08:21 AM
Brilliant Stefan!  That's worked a treat. I was so focused on the collapsing of the buttons I completely missed the fact that they're in a collection.

All fixed. Thanks for your help

regards
Ian Carson
Tags
PageView
Asked by
Ian
Top achievements
Rank 1
Answers by
Ian
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or