I am working with a tabcontrol on which I create page one with the designer. I am creating new tab pages with controls on the pages programmatically. On each page is a several panels, each with two radiobuttons (one yes,another no). There is a panel nested inside the first panel with its visible property set to false. If the user selects yes, I want the nested panel's visible property set to true which will reveal several more radiobuttons from which they must make more choices.

My problem is in changing the nested panel's property on any page other than page one.. I can detect the radiobuttons, but I can't seem to find a way to make the nested panel visible.

Public Class ControlProgram

Dim pageindx as integer

 Private Sub btnAddPrgm1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddPrgm1.Click

    Dim newTab As New TabPage()
    pageindx = (TabControl1.TabPages.Count + 1)
    newTab.Text = "Step  " & pageindx
    'define fill panel controls
    Dim newpnlFill As New Panel
    Dim newlblFill As New Label
    Dim newFillY As New RadioButton
    AddHandler newFillY.CheckedChanged, AddressOf CheckforCheckedChanged
    Dim newFillN As New RadioButton
    AddHandler newFillN.CheckedChanged, AddressOf CheckforCheckedChanged

    'add fill panel controls
    With newTab.Controls
        .Add(newpnlFill)
        With newpnlFill
            .Location = New System.Drawing.Point(6, 6)
            .Size = New System.Drawing.Size(171, 137)
            .BorderStyle = BorderStyle.FixedSingle
            .Controls.Add(newlblFill)
            With newlblFill
                .Name = "Fill"
                .Text = "Fill ?"
                .Font = New Font(newlblFill.Font, FontStyle.Bold)

                .Location = New Drawing.Point(5, 3)
            End With
            .Controls.Add(newFillY)
            With newFillY
                .Name = "FillY"
                .Text = "Yes"
                .Location = New Drawing.Point(23, 28)
                .Size = New System.Drawing.Size(43, 17)
            End With
            .Controls.Add(newFillN)
            With newFillN
                .Name = "FillN"
                .Text = "No"
                .Location = New Drawing.Point(88, 28)
                .Size = New System.Drawing.Size(39, 17)
            End With
            .Controls.Add(newpnlFill2)
            With newpnlFill2
                .Location = New System.Drawing.Point(2, 60)
                .Size = New System.Drawing.Size(164, 68)
                .BorderStyle = BorderStyle.FixedSingle
                .Visible = False
            End With
      End With
   End With
Private Sub CheckforCheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)
    If TypeOf sender Is RadioButton Then

        bEvent = CType(sender, RadioButton).Name
     End If
End Sub

End Class

I have since figured out a solution to my delima, using your suggestions as a starting point.

I added a few varribles: Dim rb as Control Dim bEvent as String Dim booFillY as Boolean Dim booFillN as Boolean

I also added the TabControl TabControl1.TabPages.Add(newTab)

I also made these changes :

    Private Sub CheckforCheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)
    If TypeOf sender Is RadioButton Then
        
        rb = sender
        bEvent = CType(sender, RadioButton).Name
        If bEvent = "FillY" Then
            Dim newpnlFill2 As Panel = rb.Parent.Controls(3)
            newpnlFill2.Visible = True
        End If
        If bEvent = "FillN" Then


            Dim newpnlFill2 As Panel = rb.Parent.Controls(3)
            newpnlFill2.Visible = False

        End If
    End If
End Sub

Now I can make the nested panel(newpnlFill2) visible or not visible by cicking the Yes or No radiobuttons on any of the tab pages created. thanks for your help. I doubt I would have ever gotten there on my own.

Might not be quite what you were looking for, but should be helpful get you where you need to go.

When I create an application, I like to build a list of all the controls for a given page in the load event so I can access them at any point. This is helpful because WinForms can be very picky about showing you child controls within a tabpage or groupbox, etc.

'Declare this variable within the class for your form (whatever)
Public arrControlsRecursive As New List(Of Control)

'method to recursively check all controls and build to array
Private Sub BuildControlsArrayRecursive(ByVal InControl As Control)
    For Each con As Control In InControl.Controls
        If con.Controls.Count > 0 Then
            BuildControlsArrayRecursive(con)
        End If
        If TypeOf con Is Control Then
            arrControlsRecursive.Add(con)
        End If
    Next
End Sub

'Call from MyBase.Load Event
BuildControlsArrayRecursive(Form1)

You can also just assemble a list of all tabs, for example, by changing the If statement to Is TypeOf con Is TabPage

Now you can loop through this collection or query it with LINQ. Find a single control by calling the first or single method. Cast to the type you want and do anything to any control anywhere within your form.