treeview tag test to label

  • Thread starter Thread starter jcoon
  • Start date Start date
J

jcoon

All,
can someone help me with a selectednode test, I'm able to get the single
selected tag values, see labels 6,7,8 but I'd like to get the tag values
from all the child nodes under a selected parent node.
I'd like to pass these values to txtpart770.Text thru txtpart775.Text see
below. This is where I NEED help to get the child tag values under the
selected parent

'gets single selected tag values from treeview
Label6.Text = "Current node selected:" & " " &
Me.TreeView1.SelectedNode.Text

'displaying the selected node


Label7.Text = "Tag Data " & TreeView1.SelectedNode.Tag()

If TreeView1.SelectedNode.Parent Is Nothing Then

Label8.Text = "Parent node index " & TreeView1.SelectedNode.Index

Else

Label8.Text = "Child node index " & TreeView1.SelectedNode.Index

End If

'here is start of my test id like get values for
If TreeView1.SelectedNode.Tag = ("Visual-Runway-A") Then

txtpart770Text = "Visual-Runway-A ' id like to get this value from the
parent tag value instead of typing text in the test

txtpart772.Text = "" ' how do I get this value

txtpart773.Text = "" ' how do I get this value

txtpart774.Text = "'" ' how do I get this value

txtpart775.Text = "" ' how do I get this value

End If


'here is a sampling of treeview values with text label that I want send tag
data to
TreeView1.Nodes.Add("Visual-Runway-A")

TreeView1.Nodes(0).Tag = ("Visual-Runway-A") ' txtpart770.Text =

TreeView1.Nodes(0).Nodes.Add("Inner Width").Tag = "250" ' txtpart771.Text =

TreeView1.Nodes(0).Nodes.Add("Outer Width").Tag = "1250" ' txtpart772.Text =

TreeView1.Nodes(0).Nodes.Add("Surface Length").Tag = "5000" '
txtpart773.Text =

TreeView1.Nodes(0).Nodes.Add("Slope").Tag = "20:1" ' txtpart774.Text =

TreeView1.Nodes(0).Nodes.Add("Radius").Tag = "5000" ' txtpart775.Text =

TreeView1.Nodes.Add("Visual-Runway-B")

TreeView1.Nodes(1).Tag = ("Visual-Runway-B") ' txtpart770.Text =

TreeView1.Nodes(1).Nodes.Add("Inner Width").Tag = "500" ' txtpart771.Text =

TreeView1.Nodes(1).Nodes.Add("Outer Width").Tag = "1500" ' txtpart772.Text
=

TreeView1.Nodes(1).Nodes.Add("Surface Length").Tag = "5000" '
txtpart773.Text =

TreeView1.Nodes(1).Nodes.Add("Slope").Tag = "20:1" ' txtpart774.Text =

TreeView1.Nodes(1).Nodes.Add("Radius").Tag = "5000" ' txtpart775.Text =

thanks

John
 
jcoon said:
All,
can someone help me with a selectednode test, I'm able to get the single
selected tag values, see labels 6,7,8 but I'd like to get the tag values
from all the child nodes under a selected parent node.
I'd like to pass these values to txtpart770.Text thru txtpart775.Text see
below. This is where I NEED help to get the child tag values under the
selected parent

'gets single selected tag values from treeview
Label6.Text = "Current node selected:" & " " &
Me.TreeView1.SelectedNode.Text

'displaying the selected node


Label7.Text = "Tag Data " & TreeView1.SelectedNode.Tag()

If TreeView1.SelectedNode.Parent Is Nothing Then

Label8.Text = "Parent node index " & TreeView1.SelectedNode.Index

Else

Label8.Text = "Child node index " & TreeView1.SelectedNode.Index

End If

'here is start of my test id like get values for
If TreeView1.SelectedNode.Tag = ("Visual-Runway-A") Then

txtpart770Text = "Visual-Runway-A ' id like to get this value from the
parent tag value instead of typing text in the test
 
James,

Thank you for your help. I'll add these and see if I can get your results.
When I add these, how does it know what parent they are attached to without
some call to the parent.

I'm very new to do net, still trying to find many of these new features
work.


txtpart772.Text = TreeView1.SelectedNode.Nodes(0).Tag
txtpart773.Text = TreeView1.SelectedNode.Nodes(1).Tag
txtpart774.Text = TreeView1.SelectedNode.Nodes(2).Tag
txtpart775.Text = TreeView1.SelectedNode.Nodes(3).Tag


Thank you, have a great day

john
 
I have assumed from your description that the node selected by the user is
the parent node you are interested in. Therefore, you can use the .Tage and
..Node() properties of that object to get the description and the child
nodes, respectively.

If, however, The selected node is a child node of the parent, the parent
node will be TreeView1.SelectedNode.Parent. Again, the .Tag and .Node()
properties of that object will give the description and child nodes
respectively. To simplify things, you could put the node of interest into
its own variable. So the whole thing would look like this:

Dim tn as TreeNode 'Variable for parent node
If TreeView1.SelectedNode.Parent Is Nothing Then
tn = TreeView1.SelectedNode 'User selected the parent
Else
tn = TreeView1.SelectedNode.Parent 'User selected a child.
End If
Label8.Text = "Parent node index " & tn.Index
txtpart770Text = tn.Tag
txtpart772.Text = tn.Nodes(0).Tag
txtpart773.Text = tn.Nodes(1).Tag
txtpart774.Text = tn.Nodes(2).Tag
txtpart775.Text = tn.Nodes(3).Tag
 
James,

Thank you so much for the descriptions..........that really helps. I think I
see the light now!
I'll try to incorporate your samples into my test. I have experience with
VBA AutoCAD object
but VB dot net is very new for me. Thank you for your help.



Have a great day
John
 
Back
Top