Disable close button for single tab

18 posts, 1 answers
  1. Marius
    Marius avatar
    21 posts
    Member since:
    Oct 2010

    Posted 25 Oct 2010 Link to this post

    We want to show the close button on some tabs in the PageView, but not all. Can the closebutton visibility be specified pr tab, instead of as a property on the parent PageView?
  2. Answer
    Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 27 Oct 2010 Link to this post

    Hello Marius,

    Sorry about the delay, to achieve this result you can use this method:
    private void HideCloseButtonForPage(RadPageViewPage page)
    {
        var pageViewStripElement = ((Telerik.WinControls.UI.RadPageViewContentAreaElement)((radPageView1.ViewElement).ContentArea)).Owner as RadPageViewStripElement;
        var stripItem = ((Telerik.WinControls.UI.RadPageViewElement)(pageViewStripElement)).Items.Where(item => item.Page == page).FirstOrDefault();
        if (stripItem != null)
        {
            stripItem.ButtonsPanel.SetValue(LightVisualElement.VisibilityProperty, Telerik.WinControls.ElementVisibility.Collapsed);
            stripItem.ButtonsPanel.SetDefaultValueOverride(LightVisualElement.VisibilityProperty, Telerik.WinControls.ElementVisibility.Collapsed);
        }
    }

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 29 Oct 2010 Link to this post

    Hello again Marius,

    I just wanted to ask if the example i provided helped you achieve the desired effect.

    If you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga
  5. Marius
    Marius avatar
    21 posts
    Member since:
    Oct 2010

    Posted 29 Oct 2010 Link to this post

    It worked perfectly, thank you.
  6. Gustavo
    Gustavo avatar
    3 posts
    Member since:
    Sep 2010

    Posted 29 Oct 2010 Link to this post

    Hi Emanuel.
    I need exactly the same as Marius, I copied the code you post, but is not working for me.
    I just debugged the code, line by line, and everyhing seems to be fine. Nothing is null, entering in all code paths, etc.

    But the close button is still working at RadPageView level, I mean, for all tabs depending on the RadPageView.ViewElement.StripButtons property settings.

    Am I missing something? might be missing a setting at the radpageview properties?

    Thanks

    Gustavo
  7. Gustavo
    Gustavo avatar
    3 posts
    Member since:
    Sep 2010

    Posted 29 Oct 2010 Link to this post

    Hi Emanuel.
    On my previous post, I think I was confusing between the RadPageView.ViewElement.StripButton property and the StripElement level.

    Now I just set RadPageView.ViewElement.StripButton to "false", and using your code, everything is working perfectly.

    Very useful code.

    Thanks

    Gustavo

  8. Kirk Couser
    Kirk Couser avatar
    26 posts
    Member since:
    Apr 2009

    Posted 01 Dec 2010 Link to this post

    Shouldn't using this line:

    SomePageView.ViewElement.ShowItemCloseButton = false;

    Set the close button visibility to false?  It is not in my case.
  9. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 02 Dec 2010 Link to this post

    Hello,

    This is set to false by default in Strip mode. Setting this to trrue will show a X (close button) on each tab.
    Hope that helps
    Richard
  10. Kirk Couser
    Kirk Couser avatar
    26 posts
    Member since:
    Apr 2009

    Posted 02 Dec 2010 Link to this post

    I have my page view in strip mode, but the close button still shows regardless that why I asked about that line of code.  I'm using the latest release in Visual Studio 2010 on a .NET 3.5 Windows App.
  11. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 02 Dec 2010 Link to this post

    Kirk,

    This will also hide the X on the strip
    Me.RadPageView1.ViewElement.Children(0).Children(1).Children(3).Visibility = ElementVisibility.Collapsed

    hope that helps
    Richard
  12. Kirk Couser
    Kirk Couser avatar
    26 posts
    Member since:
    Apr 2009

    Posted 02 Dec 2010 Link to this post

    That didn't work for me either, both the arrows and close button still show.  I'm using the page view like a wizard with command buttons to cycle through the page views so having those buttons there is confusing the end users of the app.
  13. Kirk Couser
    Kirk Couser avatar
    26 posts
    Member since:
    Apr 2009

    Posted 02 Dec 2010 Link to this post

    Nevermind I figured it out, if you go into designer mode on your page view, drill down into the ViewElement and then set StripButtons to None it will make them go away.
  14. Chad
    Chad avatar
    2 posts
    Member since:
    Aug 2012

    Posted 08 Dec 2010 Link to this post

    I also wanted to now how to hide specific buttons on a tab. Your suggestion worked:

    tabOrder.ViewElement.Children(0).Children(1).Children(3).Visibility = ElementVisibility.Collapsed

    Yet I would like to understand it.

    The Help file explains basic stuff, and when I search for less traveled topics like this and most others, I get genererated documentation that is of no help.
    I have a Page view with a few tabs. What do all these nested collections refer to? How does one go figuring this out?

    Edit:

    I see the property builder. I think that this is my best shot to understanding the control.
  15. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 08 Dec 2010 Link to this post

    Hi Chad,

    RadControls are made up of nested elements (other controls) For exmaple, a radButton would have a border element, a fill primitive element etc.. This is finding the element required to set visibility.

    If you go to the Smart Tag of a RadControl and click on Edit UI Elements, then you can see the element hierarchy for the control, and therefore control its properties.

    Hope that helps
    Richard
  16. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 08 Dec 2010 Link to this post

    Hi Chad,

    In addition to Richard's reply I can suggest that you use our RadControlSpy tool. For additional information, please refer to this article.

    Regards,
    Dobry Zranchev
    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
  17. Dan
    Dan avatar
    7 posts
    Member since:
    Jun 2012

    Posted 26 Jun 2012 Link to this post

    Sorry to bump an old thread, but my issue is so close to this that I thought this would be the best place to address it.

    I'd like to remove the close box on one individual tab itself (when ShowItemCloseButton = True).  The tab page is created programmatically.  Is this possible?

    P.S. I tried the control spy, but it didn't seem to want to pick up any controls on my MDI form.

    Thanks,
    Dan

  18. Boryana
    Admin
    Boryana avatar
    330 posts

    Posted 29 Jun 2012 Link to this post

    Hello Dan,

    Thank you for writing.

    Have you tried the following approach:
    RadPageViewPage buttonless = new RadPageViewPage();
    buttonless.Text = "Buttonless Page";
    this.radPageView1.Pages.Add(buttonless);
    buttonless.Item.ButtonsPanel.CloseButton.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;

    Once you have added the page to the Pages collection, you can easily navigate to its CloseButton and set its Visibility to collapsed.

    Feel free to write back if you have further queries.

    Kind regards,
    Boryana
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  19. Dan
    Dan avatar
    7 posts
    Member since:
    Jun 2012

    Posted 29 Jun 2012 Link to this post

    Perfect!  Thanks Boryana!
Back to Top
UI for WinForms is Visual Studio 2017 Ready