Strip Buttons not hiding when asked

6 posts, 1 answers
  1. Ian
    Ian avatar
    61 posts
    Member since:
    Jul 2010

    Posted 11 Feb 2013 Link to this post

    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;
     
        }
  2. Ian
    Ian avatar
    61 posts
    Member since:
    Jul 2010

    Posted 11 Feb 2013 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 12 Feb 2013 Link to this post

    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.
  5. Ian
    Ian avatar
    61 posts
    Member since:
    Jul 2010

    Posted 12 Feb 2013 Link to this post

    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
  6. Answer
    Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 15 Feb 2013 Link to this post

    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.
  7. Ian
    Ian avatar
    61 posts
    Member since:
    Jul 2010

    Posted 15 Feb 2013 Link to this post

    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
Back to Top
UI for WinForms is Visual Studio 2017 Ready