Here is an example i wrote, which sets the first control to visible and the second control to invisible:
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ShowPanel("Panel2", "Panel1")
End Sub
Function ShowPanel(ByVal strPanel As String, ByVal strHide As String)
Dim x As Control
Dim myFrm As Control
Label1.Text = Panel1.Parent.ID()
For Each myFrm In Me.Controls
'Find the Form
If myFrm.ID = "Form1" Then
Exit For
End If
Next
For Each x In myFrm.Controls
Select Case LCase(x.ID)
Case LCase(strPanel)
x.Visible = True
Case LCase(strHide)
x.Visible = False
End Select
Next
End Function
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
ShowPanel("Panel1", "Panel2")
End Subp