Invoking a Control by its Name string?
Visual Basic
1
Posts
1
Posters
0
Views
1
Watching
-
Greetings! I want to switch controls (panels) visibility by using their respective names (in variables). How can I get there from here:
Public prefPanel As Panel = New Panel() Private Sub uxcPreferencesForm_Load(....) Handles MyBase.Load prefPanel = Me.uxcGeneralPnl ' Startup Panel prefPanel.Visible = True End Sub Private Sub uxCatagoryTree_AfterSelect(....) Handles uxCatagoryTree.AfterSelect prefPanel.Visible = False ' Hide Current Panel Dim path As String = uxCatagoryTree.SelectedNode.FullPath Dim arrPath As Array = path.Split("\") Dim panl As String = "uxc" ' Formulate new Panel's name For i As Integer = 0 To (arrPath.Length - 2) panl += arrPath(i).ToString.Substring(0, 3) Next i panl += arrPath(arrPath.Length - 1).ToString + "Pnl" prefPanel.Name = panl ' HERE IS WHERE I GET LOST prefPanel.Visible = True ' Show New Current Panel uxHeadingLbl.Text = panl 'path End Sub
The panels are all created (and designed) at compile time - they are invisible. Is there a way to handle this switching? Thanks, Karen Nooobie to OOP and VB.Net 2005