Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tree View Question 1

Status
Not open for further replies.

shannanl

IS-IT--Management
Apr 24, 2003
1,071
US
I have a tree view that has 3 parent nodes, "Open", "Closed" and "Cancelled". Under those 3 nodes I have child nodes. When a user clicks on a child node, I need to know the tag of the node. The tag is actually the primary key of a database table. The field is called "Entry_id". I use the following code to set the tags. It works okay to add the child nodes but it sets the tag on the parent node, not the child nodes. How can I change the xxx.tag = line to set the tag for each child node?

Thanks in advance,

Shannan

'-- IF OPEN VISIT
If Trim(drData.Item("Sched_status")) = "O" Then
OpenNode.Nodes.Add(strText)
OpenNode.Tag = drData.Item("Entry_id")
End If

'-- IF CLOSED VISIT
If Trim(drData.Item("Sched_status")) = "C" Then
ClosedNode.Nodes.Add(strText)
ClosedNode.Tag = drData.Item("Entry_id")
End If

'-- IF CANCELLED VISIT
If Trim(drData.Item("Sched_status")) = "X" Then
CancelledNode.Nodes.Add(strText)
CancelledNode.Tag = drData.Item("Entry_id")
End If
 
This approach should work...
Code:
		Dim node As New TreeNode(Str.Text)
		node.Tag = drData.item("Entry_Id")
		OpenNode.Nodes.Add(node)
 
Now that was fast! Thanks for the help.

Shannan
 
Glad to help - this is a pattern that you will use a lot when working with collections:
Code:
dim obj as new Object
'set some properties for obj
Objects.Add(obj)
 
Thank you very much for the help.

Shannan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top