Treeview Node Type

C

Chris

Is there any way when progratically adding nodes to assign them some kind of
type group nodes that want to different things to. I am creating an Explorer
type interface and need to differentiate between folder and file nodes in my
code. Regards, Chris.
 
R

Robbe Morris [C# MVP]

I've done this sort of thing a variety of ways. The most flexibility
and less troublesome in regards to managing parent object references
if you do a bunch of drag and drop of tree nodes is do to
the following.

Create a simple class that has some sort of Guid or Unique ID, an
object name or possibly an enum, and a text description.

Store this object in the TreeNode.Tag property. Whenever
you get the selected node, grab the .Tag

CustomClass rob = (CustomClass)tree.SelectedNode.Tag;
 
C

Chris

I can't seem to find the tag property. This is the asp.net v2 treeview. I
use the code below to add the node but I can't do e.g. newnode.tag =
"folder"

Dim newNode As TreeNode = New TreeNode("folder", "folder")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top