Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 527
  • Last Modified:

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

0
TeDeSm
Asked:
TeDeSm
  • 5
  • 3
  • 2
2 Solutions
 
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
 
GMGeniusCommented:
Infact you can do away with the (New TreeNode) statement prefix
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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
 
GMGeniusCommented:
You may also wish to look at the .name property as well as the .tag property
0
 
John (Yiannis) ToutountzoglouInstructor 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

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

  • 5
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now