close "x" button question

2 posts, 0 answers
  1. Ken
    Ken avatar
    5 posts
    Member since:
    Aug 2008

    Posted 16 Mar 2009 Link to this post

    I using the code in the tabstrip tutorial to put a close "x" button on tabs and it works but is
    there any way to actually destroy the tabs instead of hiding or collapsing them?

    This is the code from the tutorial...

     Private Function newButton() As RadButtonElement 
     Dim radB As New RadButtonElement() 
     radB.MaxSize = New Size(12, 12) 
     AddHandler radB.Click, AddressOf HideTab 
     radB.Font = New System.Drawing.Font("Verdana", 6, FontStyle.Regular, GraphicsUnit.Point, (DirectCast(0, Byte))) 
     radB.Text = "x" 
     radB.TextAlignment = ContentAlignment.MiddleRight 
     'Alignment defines where the button will be placed on the tab 
     radB.Alignment = ContentAlignment.TopRight 
     Return radB 
    End Function 
    Private Sub HideTab(ByVal sender As Object, ByVal e As EventArgs) 
     Dim buttonElement As RadElement = (DirectCast(sender, RadElement)) 
     buttonElement.Parent.Visibility = ElementVisibility.Collapsed 
    End Sub  

  2. Martin Vasilev
    Martin Vasilev avatar
    1061 posts

    Posted 19 Mar 2009 Link to this post

    Hi Ken,

    Thank you for the question.

    Yes, you can dispose TabItem instead of hiding it. To do this you have to remove it from the RadTabStrip Items collection. Please, review the following revised HideTab event:

    Private Sub HideTab(ByVal sender As ObjectByVal e As EventArgs)   
        Dim buttonElement As RadElement = DirectCast(sender, RadElement)   
        'buttonElement.Parent.Visibility = ElementVisibility.Collapsed;   
        Dim tab As TabItem = TryCast(buttonElement.Parent, TabItem)   
        If tab IsNot Nothing Then   
        End If   
    End Sub  

    Do not hesitate to contact me again if you have other questions.

    Sincerely yours,
    Martin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft R3 2016 release webinar banner
Back to Top