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

  • SEARCH
  • Home
  • 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 6330279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:50:35+00:00 2026-05-24T17:50:35+00:00

I use the following code to display xml as a treeview. Now I want

  • 0

I use the following code to display xml as a treeview.

Now I want to refresh when I edit xml by using some text box in same window. When I edit and save file using textbox I want to refresh treeview also with that new value.

How can I do it?

I use treeview1.update(); and treeview1.refresh(); but it’s not working.

I used the following code part:

private void button1_Click(object sender, EventArgs e)
{
    XmlDataDocument xmldoc = new XmlDataDocument();
    XmlNode xmlnode ;
    FileStream fs = new FileStream("tree.xml", FileMode.Open, FileAccess.Read);
    xmldoc.Load(fs);
    xmlnode = xmldoc.ChildNodes[1];
    treeView1.Nodes.Clear();
    treeView1.Nodes.Add(new TreeNode(xmldoc.DocumentElement.Name));
    TreeNode tNode ;
    tNode = treeView1.Nodes[0];
    AddNode(xmlnode, tNode);
}

private void AddNode(XmlNode inXmlNode, TreeNode inTreeNode)
{
    XmlNode xNode ;
    TreeNode tNode ;
    XmlNodeList nodeList ;
    int i = 0;
    if (inXmlNode.HasChildNodes)
    {
        nodeList = inXmlNode.ChildNodes;
        for (i = 0; i <= nodeList.Count - 1; i++)
        {
            xNode = inXmlNode.ChildNodes[i];
            inTreeNode.Nodes.Add(new TreeNode(xNode.Name));
            tNode = inTreeNode.Nodes[i];
            AddNode(xNode, tNode);
        }
    }
    else
    {
        inTreeNode.Text = inXmlNode.InnerText.ToString();
    }
}
  • 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-24T17:50:35+00:00Added an answer on May 24, 2026 at 5:50 pm

    You can create the treeview completely new after saving your changes. In order to reuse your existing code, you could refactor it a bit:

    private void button1_Click(object sender, EventArgs e)
    {
      this.FillTreeView();
    }
    private void FillTreeView()
    {
        XmlDataDocument xmldoc = new XmlDataDocument();
        XmlNode xmlnode ;
        FileStream fs = new FileStream("tree.xml", FileMode.Open, FileAccess.Read);
        xmldoc.Load(fs);
        xmlnode = xmldoc.ChildNodes[1];
        treeView1.Nodes.Clear();
        treeView1.Nodes.Add(new TreeNode(xmldoc.DocumentElement.Name));
        TreeNode tNode ;
        tNode = treeView1.Nodes[0];
        AddNode(xmlnode, tNode);
    }
    private void AddNode(...) { ... }
    

    …and after saving your modifications to the xml file, call FillTreeView():

    private void button2_Click(object sender, EventArgs e)
    {
      // [Save changes to file]
      this.FillTreeView();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use the following code, to display $formcode, which is the
I use the following code to layout network drives on a system. I want
I am using the XML tag android:configChanges=orientation|keyboardHidden|keyboard and the following code to detect device
I use the following code to display a map center on the user's location:
I have use following code to display category and there product on click patent
I use the following code to display a product. 3 products per row (each
I use the following code to display a tooltip <asp:GridView ID=GridView1 runat=server AutoGenerateColumns=False DataKeyNames=ID
I use the following code to display list of contacts, and then retrieve contact
I use the following code to load some banners: a banner is a clickable
Appreciate some insight given the following code: <script type=text/javascript> $(document).ready(function() { var soapEnv =

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.