Click here to Skip to main content
15,891,184 members

Comments by stopete82 (Top 25 by date)

stopete82 23-May-11 13:36pm View    
Thanks this is what I was looking for.
stopete82 13-May-11 14:43pm View    
Thanks for your help, this is the code that worked for me:

Private Sub TreeView1_AfterCheck(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterCheck



Dim Pnode As TreeNode = e.Node


Dim PPnode As TreeNode = Pnode.Parent


If Pnode.Checked = True Then
While PPnode IsNot Nothing
RemoveHandler PPnode.TreeView.AfterCheck, AddressOf TreeView1_AfterCheck
PPnode.Checked = True
AddHandler PPnode.TreeView.AfterCheck, AddressOf TreeView1_AfterCheck
PPnode = PPnode.Parent
End While
Else
UncheckParent(PPnode)
End If

End Sub
stopete82 13-May-11 13:17pm View    
Syntax problem:

Dim nodes As TreeNodeCollection

For each node as treenode in nodes
If childrennode.checked = True Then
Parentnode.check = True
End If
Next
with this code I get childrennode not declared and parentnode change to Treenode.
stopete82 13-May-11 10:52am View    
Your totally right; thanks for the advice. This worked for me:

This code gave me the leader and the controlfields nodes:

For Each Record As XElement In doc...<record>

recordNode = TreeView1.Nodes.Add(Record.Name.ToString)


For Each Leader As XElement In Record...<leader>

leaderNode = recordNode.Nodes.Add(Leader.Name.ToString)



For Each Controlfield As XElement In Record...<controlfield>
controlfieldNode = recordNode.Nodes.Add(Controlfield.@tag.ToString)

Next

Next

Next

This code gave me the datafield nodes:

For Each Record As XElement In doc...<record>

recordNode = TreeView1.TopNode
For Each Datafield As XElement In Record...<datafield>
datafielNode = recordNode.Nodes.Add(Datafield.@tag.ToString)

For Each Subfield As XElement In Datafield...<subfield>
datafielNode.Nodes.Add(Subfield.@code.ToString)

Next
Next
Next
stopete82 11-May-11 13:05pm View    
Thanks Fabio V Silva for the great idea. This is the code that worked for me. Thanks again

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

For Each n As TreeNode In GetCheck(TreeView1.Nodes)
MsgBox(n.Text)
Next


End Sub

Private Function GetCheck(ByVal node As TreeNodeCollection) As List(Of TreeNode)

Dim lN As New List(Of TreeNode)
For Each n As TreeNode In node
If n.Checked Then lN.Add(n)
lN.AddRange(GetCheck(n.Nodes))
Next

Return lN

End Function