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

How-to access all controls in a TabStrip

2 Answers 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.
Marc-Andre
Top achievements
Rank 1
Marc-Andre asked on 23 Feb 2009, 03:42 PM
Hi there, is there a way to access all controls on a specific tabstrip page? The reason is that I have multiple pages in a tabstrip and they all contain different controls. I need to be able to set some properties to each controls but I can't find how to access them.

I need to acheive something like this :

For i = 0 To veTabSoumission.Items.Count - 1

                For Each myControl In veTabSoumission.Items(i).controls

                    If TypeOf myControl Is CheckBox Then

                        DirectCast(myControl, CheckBox).Enabled = False

                    ElseIf TypeOf myControl Is TextBox Then

                        DirectCast(myControl, TextBox).ReadOnly = True

                    ElseIf TypeOf myControl Is RichTextBox Then

                        DirectCast(myControl, RichTextBox).ReadOnly = True

                    ElseIf TypeOf myControl Is DateTimePicker Then

                        DirectCast(myControl, DateTimePicker).Enabled = False

                    ElseIf TypeOf myControl Is ComboBox Then

                        DirectCast(myControl, ComboBox).Enabled = False

                    ElseIf TypeOf myControl Is Button Then

                        DirectCast(myControl, Button).Enabled = False

                    ElseIf TypeOf myControl Is RadioButton Then

                        DirectCast(myControl, RadioButton).Enabled = False

                    ElseIf TypeOf myControl Is PictureBox Then

                        DirectCast(myControl, PictureBox).Enabled = False

                    End if

            Next



Thanks!!

 

 

 

 

 

 

 

 

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Deyan
Telerik team
answered on 26 Feb 2009, 09:18 AM
Hello Marc-Andre,

Thanks you for contacting us.

You can consider the following code snippet:

 for (int panelIndex = 0; panelIndex < this.radTabStrip1.Controls.Count; panelIndex++) 
     RadTabStripContentPanel currentTab = this.radTabStrip1.Controls[panelIndex] as RadTabStripContentPanel; 
 
     if (currentTab != null
     { 
        for (int controlIndex = 0; controlIndex < currentTab.Controls.Count; controlIndex++) 
        { 
            Control currentControl = currentTab.Controls[controlIndex]; 
 
        } 
    }      

Basically, what I do is to iterate over the RadTabStripContentPanels which represent the pages for each tab in the RadTabStrip control. For each RadTabStripContentPanel I use again the Controls collection in order to access the items that are in this content panel.

I hope this will help you to achieve your goal. Do not hesitate to get back to me if you need further assistance.

Sincerely yours,
Deyan
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
Marc-Andre
Top achievements
Rank 1
answered on 26 Feb 2009, 03:16 PM
I did minor modifications to your code and it worked like a charm!

Thanks a lot!
Tags
Tabstrip (obsolete as of Q2 2010)
Asked by
Marc-Andre
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Marc-Andre
Top achievements
Rank 1
Share this question
or