Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8934627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:50:01+00:00 2026-06-15T09:50:01+00:00

I have already read this question which talks about the same thing but I

  • 0

I have already read this question which talks about the same thing but I had a specific question about the design. As you know the options dialog in VS is a TreeView control on the left and a panel like control on the right which houses all the options for the current selection of the TreeView control. Based on the advice given in the above question I decided to build a UserControl for each “panel” of options. I am trying to decide the best way to make the selected panel visible and all other panels hidden when you user picks a specific node in the TreeView. In my event handler for when a new node in the TreeView is selected a do the following:

        If e.Node.Name.CompareTo("PanelAName") = 0 Then
            PanelA.Visible = True
            PanelA.Enabled = True

            PanelB.Visible = False
            PanelB.Enabled = False

        ElseIf e.Node.Name.CompareTo("PanelBName") = 0 Then
            PanelA.Visible = False
            PanelA.Enabled = False

            PanelB.Visible = True
            PanelB.Enabled = True

        End If

The only problem is instead having just the two panels in the sample code I am going to have like 15-25. While I could certainly still do it like this it seems like a lot more lines of code then should be need. Any suggestions on a better way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:50:02+00:00Added an answer on June 15, 2026 at 9:50 am

    You can try utilizing the Tag property of the node to hold the name of the associated panel, then try looping over the panels in the form and compare the node name with the panel name:

    private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) {
      foreach (Panel p in this.Controls.OfType<Panel>()) {
        if (p.Name == e.Node.Tag.ToString()) {
          p.Visible = true;
        } else {
          p.Visible = false;
        }
      }
    }
    

    You can add a reference from each panel into the node’s tag property, as well:

    private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) {
      foreach (Panel p in this.Controls.OfType<Panel>()) {
        p.Visible = e.Node.Tag.Equals(p);
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question was asked already here , but rather than answering the specific question,
I have question about sending emails from MVC3 application. I already read for exmple
Well, first I know that this question was already asked several times. But I
Possible Duplicate: What’s with the love of dynamic Languages I have already read this
I have read some threads regarding this and I did already take steps to
I have already read some posts, but no one helped me with my problem.
I have already read all the previous similar posts but I couldn't find a
I read this question , which highlights a solution to conditionally insert values into
I know this might sound like something which is explained everywhere.. but I've been
This question has been already asked, but never answered. I want to write some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.