How-to access all controls in a TabStrip

3 posts, 1 answers
  1. Marc-Andre
    Marc-Andre avatar
    47 posts
    Member since:
    Jan 2009

    Posted 23 Feb 2009 Link to this post

    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. Answer
    Deyan
    Admin
    Deyan avatar
    2039 posts

    Posted 26 Feb 2009 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Marc-Andre
    Marc-Andre avatar
    47 posts
    Member since:
    Jan 2009

    Posted 26 Feb 2009 Link to this post

    I did minor modifications to your code and it worked like a charm!

    Thanks a lot!
Back to Top