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 1928512
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:59:16+00:00 2026-05-17T06:59:16+00:00

Ok, I have a treeview which I am using to display a number of

  • 0

Ok, I have a treeview which I am using to display a number of nodes. I wish to attach data (three textbox fields) to each node but I do not want to show it in the tree. I wish to save the data to a string[] Array if possible. I want the data in the boxes to save to the Arrays when I click on a new node in the tree and pull the information from the Arrays for the new node.

For some reason the code I have does not work. It doesn’t save the information and sometimes it just shows random data in the text boxes as I click about. The code is:

    These are global variables within the form:
    string[] desc1;
    string[] desc2;
    string[] desc3;

 private void treeView1_BeforeSelect(object sender, TreeViewEventArgs e)
    {

          // save the entered text into the local variables
        desc1[treeView1.SelectedNode.Index] = textBox4.Text;
        desc2[treeView1.SelectedNode.Index] = textBox5.Text;
        desc3[treeView1.SelectedNode.Index] = textBox6.Text;

    }

    private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
    {

        // update labels
        label23.Text = treeView1.SelectedNode.Text.ToString();
        label24.Text = (treeView1.SelectedNode.Index + 1).ToString();

        // enable all textbox fields
        textBox4.Enabled = true;
        textBox5.Enabled = true;
        textBox6.Enabled = true;

        // clear all textbox fields
        textBox4.Text = null;
        textBox5.Text = null;
        textBox6.Text = null;



        // if parent is selected then show as unselected - if not update text fields
        if (treeView1.SelectedNode.Text.ToString() == "Parent Name")
        {
            label23.Text = "Unselected";
            label24.Text = "Unselected";
            textBox4.Enabled = false;
            textBox5.Enabled = false;
            textBox6.Enabled = false;
        }
        else
        {
            // show the information from the array in the text fields
            textBox4.Text = desc1[treeView1.SelectedNode.Index];
            textBox5.Text = desc2[treeView1.SelectedNode.Index];
            textBox6.Text = desc3[treeView1.SelectedNode.Index];
        }

    }

Anyone have an idea of what I can do? I have trawled google now for 24hours with no luck.
Thanks!

  • 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-05-17T06:59:16+00:00Added an answer on May 17, 2026 at 6:59 am

    The TreeNodes have a Tag property that you can use to attach any sort of data that you would like.

    You would use it like this:

    // To set the data:
    myTreeNode.Tag = new string[] { "1", "2", "3" };
    
    // To read the data:
    var data = myTreeNod.Tag as string[];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WinForms TreeView with one main node and several sub-nodes. How can
I have a treeview which i populate dynamically using an XML Datasource. The leaf
I have a TreeView which has three levels. Lets say its a league, division
I have a treeview with nodes like this: Foo (1234), and want to allow
I have a treeview control on an aspx page. The data comes from database
Using WPF, I have a TreeView control that I want to set its ItemTemplate
I am using a treeview to display projects, tasks, time entries, and the people
I have a TreeView which i build up in code recursively. I would like
I have a TreeView with a given width. When I add a node with
I will have some sort of nodes for a treeview as follows Root |->

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.