473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

c# TreeView how to hide root node

Hi,

Is it possible to hide the root node in a treeview without editing the original xml?

To populate the xml file, I am using this functions:

Expand|Select|Wrap|Line Numbers
  1. private void PopulateTree(TreeView myTreeView, XmlDocument myXmlDoc)         
  2. {
  3.            myTreeView.Nodes.Clear();                               
  4.            myTreeView.Nodes.Add(new TreeNode(myXmlDoc.DocumentElement.Name));
  5.            TreeNode tNode = new TreeNode();
  6.            tNode = (TreeNode)myTreeView.Nodes[0];               
  7.            AddNode(myTreeView, myXmlDoc.DocumentElement, tNode);
  8.            myTreeView.ExpandAll();
  9. }
  10.  
  11. private void AddNode(TreeView myTreeView, XmlNode inXmlNode, TreeNode inTreeNode)
  12. {
  13.             XmlNode xNode;
  14.             TreeNode tNode;
  15.             XmlNodeList nodeList;
  16.  
  17.             if (inXmlNode.HasChildNodes)
  18.             {
  19.                 nodeList = inXmlNode.ChildNodes;
  20.                 for (int i = 0; i <= nodeList.Count - 1; i++)
  21.                 {
  22.                     xNode = inXmlNode.ChildNodes[i];
  23.                     inTreeNode.Nodes.Add(new TreeNode(xNode.Attributes["name"].Value));
  24.                     tNode = inTreeNode.Nodes[i];
  25.                     AddNode(myTreeView, xNode, tNode);
  26.                 }
  27.             }
  28.             else
  29.             {
  30.               //inTreeNode.Text = (inXmlNode.OuterXml).Trim();                
  31.             }
  32. }
  33.  
Thanks for your replies.
Mar 23 '07 #1
0 2610

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Don Wash | last post by:
Hi There! I'm using VB.NET to create a TreeView application and unfortunately I could not find "Key" property in Node items of the TreeView. We used to have "Key" property in TreeView node...
6
by: L.M | last post by:
Hello, I knew how to use the treeview under VB6. After migrating to .NET, well, I'm lost. I try to add a new node, either to the same level or as a child to a selected node in the treeview....
9
by: Marina | last post by:
Hello! I have a database with some customers. Each one of them has 3 other customers under him etc. (something like an MLM system). Now, I want to create a treeview with this. Eg. C1 C11...
7
by: amruta | last post by:
the code below dows not let me get the parent child view... all the nodes are show in one line only... also i need them to be collasped ... Thanks ..
10
by: p3t3r | last post by:
I have a treeview sourced from a SiteMap. I want to use 2 different CSS styles for the root level nodes. The topmost root node should not have a top border, all the other root nodes should have a...
4
by: hartbypass | last post by:
Hello, I have treeview control that I am populating with a XML file. The structure is: Treenode Level 1 Item1 Item2 Item3
1
by: JRSofty | last post by:
Hi everyone, I've gotten myself is bit of a mess where I'm loading a treeview. Basically I initialize the treeview control with a single root node we'll call it root. I do this by using the...
11
by: pbd22 | last post by:
Hi. I am getting odd treeview results and hope you can help. I am parsing a string, "x/y/z", turning it into an array (that always seems to start with an empty string) and then using the...
4
by: jmDesktop | last post by:
I have searched everywhere and tried several things. I have a treeview with and want to be able to only select a parent node. For example: root //don't want to drag this -parent1 //yes, drag...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.