Disable the close button in RadPageview strip mode

14 posts, 1 answers
  1. Divya
    Divya avatar
    47 posts
    Member since:
    Mar 2011

    Posted 29 Mar 2011 Link to this post

    Hi
                I am using the strip mode of the RadPageView i want to disable the close button can anyone explain how to do.....



    Thanks
    Divya
  2. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 29 Mar 2011 Link to this post

    Hello,

    If you go to the Smart Tag for the control, then you can set which buttons you would like to see in the RadPageView using the StripButtons property. There is a screenshot in this help topic

    hope that helps
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. David
    David avatar
    2 posts
    Member since:
    Nov 2012

    Posted 19 Nov 2012 Link to this post

    Is there a way to disable/remove the close icon/button on the page view programatically?
  5. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 22 Nov 2012 Link to this post

    Hello David,

    Thank you for your question.

    In order to hide the close buttons, you should consider setting the following properties:
    (radPageView1.ViewElement as RadPageViewStripElement).ShowItemCloseButton = false;
    (radPageView1.ViewElement as RadPageViewStripElement).StripButtons = StripViewButtons.Scroll;

    I hope this helps. If you have any further questions, feel free to ask.

    All the best,
    Ivan Todorov
    the Telerik team
  6. Brendan
    Brendan avatar
    52 posts
    Member since:
    Dec 2011

    Posted 21 Feb 2013 Link to this post

    Is it possible to display the close button on selected tabs only?  I want to allow users to close some tabs, but not others.  Thanks.

  7. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 26 Feb 2013 Link to this post

    Hello Brendan,

    You can do that by using the following code in the SelectedPageChanging event:
    void radPageView1_SelectedPageChanging(object sender, RadPageViewCancelEventArgs e)
    {
        radPageView1.SelectedPage.Item.ButtonsPanel.CloseButton.Visibility = ElementVisibility.Collapsed;
        e.Page.Item.ButtonsPanel.CloseButton.Visibility = ElementVisibility.Visible;
    }

    I hope this helps.
     

    Regards,
    Stefan
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  8. Brendan
    Brendan avatar
    52 posts
    Member since:
    Dec 2011

    Posted 26 Feb 2013 Link to this post

    Thank you Stefan, it works fine.  I'm trying to figure out how to have the close button appear when I hover over a page, the same as VS 2012 does.  How would I achieve that - in the MouseEnter or MouseHover event?

    Here is the code I used for when a tab is changed, I would still need this.  I wasn't sure how to identify the page I never want closed, so I used the name (pgmain).  I also had to add the On Error part as I was getting an error when starting the project. "An error occurred creating the form. See Exception.InnerException for details.  The error is: Object reference not set to an instance of an object."

    Private Sub pageViewDocs_SelectedPageChanging(sender As Object, e As RadPageViewCancelEventArgsHandles pageViewDocs.SelectedPageChanging
         On Error Resume Next
        pageViewDocs.SelectedPage.Item.ButtonsPanel.CloseButton.Visibility = ElementVisibility.Collapsed
        If e.Page.Name.ToLower <> "pgmain" Then
            e.Page.Item.ButtonsPanel.CloseButton.Visibility = ElementVisibility.Visible
        End If
    End Sub
  9. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 01 Mar 2013 Link to this post

    Hello Brendan,

    Thank you for writing back.

    To show the close button, only when the item is hovered, you can use the MouseMove event of the control:
    Private previouslyHoveredItem As RadPageViewStripItem
    Private Sub radPageView1_MouseMove(sender As Object, e As MouseEventArgs)
        If previouslyHoveredItem IsNot Nothing Then
            previouslyHoveredItem.ButtonsPanel.CloseButton.Visibility = ElementVisibility.Collapsed
        End If
     
        Dim hoveredItem As RadPageViewStripItem = TryCast(radPageView1.ElementTree.GetElementAtPoint(e.Location), RadPageViewStripItem)
        If hoveredItem IsNot Nothing Then
            hoveredItem.ButtonsPanel.CloseButton.Visibility = ElementVisibility.Visible
            previouslyHoveredItem = hoveredItem
        End If
    End Sub

    As to the exception that you are getting, it is caused by the fact that the first time the event is fired, the control still does not have its SelectedPage set, so it is null and throws an exception when you try to access it. You can overcome this with a simple check:
    Private Sub RadPageView1_SelectedPageChanging(sender As System.Object, e As Telerik.WinControls.UI.RadPageViewCancelEventArgs) Handles RadPageView1.SelectedPageChanging
          If RadPageView1.SelectedPage IsNot Nothing Then
              RadPageView1.SelectedPage.Item.ButtonsPanel.CloseButton.Visibility = ElementVisibility.Collapsed
          End If
          If e.Page.Name.ToLower <> "pagepageviewpage2" Then
              e.Page.Item.ButtonsPanel.CloseButton.Visibility = ElementVisibility.Visible
          End If
      End Sub

    I hope that you find my answer useful. 

    Kind regards,
    Stefan
    the Telerik team
    WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Join us for a FREE webinar to see all the new stuff in action.

    Interested, but can’t attend? Register anyway and we’ll send you the recording.
  10. Brendan
    Brendan avatar
    52 posts
    Member since:
    Dec 2011

    Posted 05 Mar 2013 Link to this post

    Thank you for the help Stefan!
  11. Francisco
    Francisco avatar
    4 posts
    Member since:
    Apr 2012

    Posted 12 Mar 2014 Link to this post

    In Desing Mode:

    You can select ViewElement Option and then Search Strip Buttons Option and set it to None.

    RadPageView >> ViewElement >> Strip Buttons >> None

    You can see the image attached.
  12. Odne
    Odne avatar
    2 posts
    Member since:
    Nov 2012

    Posted 10 Apr 2014 Link to this post

    Hi!

    I would like to show everything except the close button.
    I would like to show both the scroll and the item list, but not the close button.

    Is that possible?
    The answers in this thread does not seem to solve this problem.

    Regards
    Odne Røv
  13. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 10 Apr 2014 Link to this post

    Hi Odne,

    Thank you for writing.

    To show everything but the close button you can use this code:
    ((RadPageViewStripElement)radPageView1.ViewElement).StripButtons |= ~StripViewButtons.Close;

    To have just Scroll and ItemList:
    ((RadPageViewStripElement)radPageView1.ViewElement).StripButtons = StripViewButtons.Scroll | StripViewButtons.ItemList;

    I hope this helps.

    Regards,
    Stefan
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  14. Odne
    Odne avatar
    2 posts
    Member since:
    Nov 2012

    Posted 10 Apr 2014 in reply to Stefan Link to this post

    Nice!
    This worked perfectly.

    Than you for the quick response.

    Odne
  15. Iron
    Iron avatar
    1 posts
    Member since:
    Mar 2012

    Posted 02 Nov 2015 in reply to Francisco Link to this post

    Good!! thanks a lot
Back to Top
UI for WinForms is Visual Studio 2017 Ready