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

Disable the close button in RadPageview strip mode

14 Answers 971 Views
PageView
This is a migrated thread and some comments may be shown as answers.
Divya
Top achievements
Rank 1
Divya asked on 29 Mar 2011, 09:35 AM
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

14 Answers, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 29 Mar 2011, 10:52 PM
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
0
David
Top achievements
Rank 1
answered on 19 Nov 2012, 06:31 PM
Is there a way to disable/remove the close icon/button on the page view programatically?
0
Ivan Todorov
Telerik team
answered on 22 Nov 2012, 03:16 PM
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
0
Brendan
Top achievements
Rank 1
answered on 22 Feb 2013, 02:22 AM
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.

0
Stefan
Telerik team
answered on 26 Feb 2013, 12:55 PM
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.
0
Brendan
Top achievements
Rank 1
answered on 26 Feb 2013, 03:29 PM
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
0
Stefan
Telerik team
answered on 01 Mar 2013, 01:55 PM
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.
0
Brendan
Top achievements
Rank 1
answered on 05 Mar 2013, 07:45 PM
Thank you for the help Stefan!
0
Francisco
Top achievements
Rank 2
answered on 12 Mar 2014, 04:20 PM
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.
0
Odne
Top achievements
Rank 1
answered on 10 Apr 2014, 06:33 AM
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
0
Stefan
Telerik team
answered on 10 Apr 2014, 10:21 AM
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.

 
0
Odne
Top achievements
Rank 1
answered on 10 Apr 2014, 10:32 AM
Nice!
This worked perfectly.

Than you for the quick response.

Odne
0
Iron
Top achievements
Rank 1
answered on 02 Nov 2015, 07:37 AM
Good!! thanks a lot
0
Javad
Top achievements
Rank 1
answered on 09 Feb 2018, 12:50 PM
Thanks
Tags
PageView
Asked by
Divya
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
David
Top achievements
Rank 1
Ivan Todorov
Telerik team
Brendan
Top achievements
Rank 1
Stefan
Telerik team
Francisco
Top achievements
Rank 2
Odne
Top achievements
Rank 1
Iron
Top achievements
Rank 1
Javad
Top achievements
Rank 1
Share this question
or