vb.net TreeView how to set value property

I am filling a TreeView using the code below, how do I set the value property for each of the two add new node lines? Just having trouble with syntax.
' Add a root TreeNode for each Company object in the ArrayList.
Dim company2 As Company
For Each company2 In companyArray

   tvwPreAlert.Nodes.Add(New TreeNode(company2.CompanyLedgerType + " ~ " + company2.CompanyName))
      
' Add a child TreeNode for each PreAlert object in the current Company object.

Dim prealert1 As PreAlertNumber
   For Each prealert1 In company2.CompanyPreAlerts

   tvwPreAlert.Nodes(companyArray.IndexOf(company2)).Nodes.Add( New TreeNode(prealert1.PreAlertID))

   Next prealert1
Next company2

Open in new window

TeDeSmAsked:
Who is Participating?
 
GMGeniusConnect With a Mentor Commented:
You may also wish to look at the .name property as well as the .tag property
0
 
GMGeniusCommented:
best way is to add a Node variable
like so (not tested
Dim xNode as Node
xNode =  tvwPreAlert.Nodes.Add(New TreeNode(company2.CompanyLedgerType + " ~ " + company2.CompanyName))
xNode.Value = "your value"
0
 
GMGeniusCommented:
Sorry

Dim xNode As TreeNode
 
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
GMGeniusCommented:
Infact you can do away with the (New TreeNode) statement prefix
0
 
John (Yiannis) ToutountzoglouInstructor Multiengine PilotCommented:
0
 
TeDeSmAuthor Commented:
Thanks for the help.

I have the following, however the Value property is not available, whereas Text is.

I may have to include record ID's as part of the text and parse it out for use, a bit like I had to do in MS Access VBA activeX treeview control.

Dim company2 As Company
Dim tvwNode As TreeNode
For Each company2 In companyArray

tvwNode = tvwPreAlert.Nodes.Add(company2.CompanyLedgerType + " ~ " + company2.CompanyName)
0
 
John (Yiannis) ToutountzoglouInstructor Multiengine PilotCommented:
Read about the Tag Property....
0
 
John (Yiannis) ToutountzoglouConnect With a Mentor Instructor Multiengine PilotCommented:
0
 
TeDeSmAuthor Commented:
Just the job I can give these node properties a value, I should be able to get to them fairly easily later on.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.