Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello !

 

I'm a beginner in vb.net and I need a little help. I have a XML file which as this structure :

 

<index>

<node>

<text>blublu</text>

<text>blublu</text>

</node>

<node>

<text>blublu</text>

<text>blublu</text>

<text>blublu</text>

</node>

<node>

<text>blublu</text>

<text>blublu</text>

</node>

...

</index>

 

Each node represents a root node in the treeview and each text is a child. I would like to put this into the treeview. But it seems a bit complicated. In vb6, it was ok, but with .net...ARGH !

 

When I put node via the graphic interface, I have that :

 

tvListeParam.Nodes.AddRange(New System.Windows.Forms.TreeNode() {New System.Windows.Forms.TreeNode("Node", New System.Windows.Forms.TreeNode() {New System.Windows.Forms.TreeNode("blublu"), New System.Windows.Forms.TreeNode("blublu"), New System.Windows.Forms.TreeNode("blublu")}), New System.Windows.Forms.TreeNode("Node", New System.Windows.Forms.TreeNode() {New System.Windows.Forms.TreeNode("blublu")})})

 

Is there a better way than this to create a treeview dynamically ?

Thank you !

Posted

Ups, it's a bit hard to understand. Maybe I ask a question more easy. In fact, what I would like to do, it's to insert a node where I want.

I saw the Insert method "myTreeView.Nodes.Insert()" . But I need an integer which represents the specified location of the new node.

I tried, but I can't understand where I can get it...There is a method "mytreeView.Nodes.IndexOf" but I don't understand it (sob)...:(

 

If anyone knows, I will say a big "THANKS"

  • *Gurus*
Posted

In .NET, you add children directly to a node, not to the main treeview. You only add top-level nodes to the main treeview. After that, you use the Nodes collection of each node you add.

 

You are correct about using the Insert method if you need to control the position of a node in the list of children, but I don't think that's what you're after.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...