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

close "x" button question

1 Answer 97 Views
Tabstrip (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ken
Top achievements
Rank 1
Ken asked on 16 Mar 2009, 03:09 PM
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  

1 Answer, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 19 Mar 2009, 07:04 AM
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   
        Me.radTabStrip1.Items.Remove(tab)   
        tab.Dispose()   
    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.
Tags
Tabstrip (obsolete as of Q2 2010)
Asked by
Ken
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Share this question
or