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

Check if dynamically added tab exists

5 Answers 502 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.
junk smith
Top achievements
Rank 1
junk smith asked on 06 Aug 2009, 10:18 PM
I have a radtabstrip in a VB.NET project. examples to add and remove tabs have been noted and used.
using values from a database, tabs with unique names are created. how do i check whether the tab already exists prior to creating it?

Cheers


  

5 Answers, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 12 Aug 2009, 07:11 AM
Hi junk smith,

Thank you for writing. You can check if the tab item exists by implementing simple iteration over the Items collection. Or you can use Array.Exists method as well. Please, consider the following code:

Private Sub Form1_Load(ByVal sender As ObjectByVal e As EventArgs)  
    If Array.Exists(Of RadItem)(Me.radTabStrip1.Items.ToArray(), FindItem) Then 
        'do something...  
    End If 
End Sub 
 
Private Shared Function FindItem(ByVal item As RadItem) As Boolean 
    If item.Name.Equals("My_Tab_Name"Then 
        Return True 
    Else 
        Return False 
    End If 
End Function 

I hope this helps. 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.
0
junk smith
Top achievements
Rank 1
answered on 14 Aug 2009, 11:00 AM
Hi

Thanks for the reply, i came up with a different way;

 For Each ti As TabItem In tabcontrol.Items
                If ti.Name = TABNAMETOCHECK Then
                    TabExists = True

                End If

            Next
0
Nick
Telerik team
answered on 14 Aug 2009, 11:04 AM
Hello junk smith,

I am glad that you found a better approach for your application. Thank you for sharing it with the community.

Best wishes,
Nick
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.
0
junk smith
Top achievements
Rank 1
answered on 14 Aug 2009, 03:50 PM
Only different, not necessarily better

Cheers


0
Erwin
Top achievements
Rank 1
answered on 22 Oct 2009, 10:33 PM
Even better:

Private Sub Form1_Load(ByVal sender As ObjectByVal e As EventArgs)   
    If Not Me.radTabStrip1.Items.SingleOrDefault(Function(s) s.Name.Equals("My_Tab_Name")) Is Nothing Then  
        'do something...   
    End If  
End Sub  

:-)

(Works starting from VB9).
Tags
Tabstrip (obsolete as of Q2 2010)
Asked by
junk smith
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
junk smith
Top achievements
Rank 1
Nick
Telerik team
Erwin
Top achievements
Rank 1
Share this question
or