I have a form with 6 panels and 6 buttons. How can I display one panel and hide the others when I press a button, and then vice versa. Here is a sample of my code, but it does not work:
Public Class FormShow
Private fobjCurrentPanel As Panel
Private Sub SelectedPanel(ByVal pobjPanel As Panel)
Try
If Not fobjCurrentPanel Is Nothing Then
fobjCurrentPanel.SendToBac
k()
fobjCurrentPanel.Visible = False
fobjCurrentPanel = Nothing
End If
fobjCurrentPanel = pobjPanel
fobjCurrentPanel.Visible = True
fobjCurrentPanel.BringToFr
ont()
Catch
End Try
End Sub
Private Sub btnA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnA.Click
SelectedPanel(panA)
End Sub
Private Sub btnB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnB.Click
SelectedPanel(panB)
End Sub
Private Sub btnC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnC.Click
SelectedPanel(panC)
End Sub
End Class
Start Free Trial