Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

vb.net TreeView how to set value property

Posted on 2010-09-06
10
Medium Priority
?
524 Views
Last Modified: 2013-11-27
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
Comment
Question by:TeDeSm
  • 5
  • 3
  • 2
10 Comments
 
LVL 12

Expert Comment

by:GMGenius
ID: 33612094
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
 
LVL 12

Expert Comment

by:GMGenius
ID: 33612106
Sorry

Dim xNode As TreeNode
 
0
 
LVL 12

Expert Comment

by:GMGenius
ID: 33612120
Infact you can do away with the (New TreeNode) statement prefix
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 12

Expert Comment

by:GMGenius
ID: 33612122
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33612152
0
 

Author Comment

by:TeDeSm
ID: 33612230
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
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33612235
Read about the Tag Property....
0
 
LVL 12

Accepted Solution

by:
GMGenius earned 1000 total points
ID: 33612261
You may also wish to look at the .name property as well as the .tag property
0
 
LVL 18

Assisted Solution

by:John (Yiannis) Toutountzoglou
John (Yiannis) Toutountzoglou earned 1000 total points
ID: 33612275
0
 

Author Closing Comment

by:TeDeSm
ID: 33612288
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question