How to set all nodes checked = false, on a treeview

  • Thread starter Thread starter Just Me
  • Start date Start date
J

Just Me

I need to set all nodes on a treeview so that checked=0

Is there a good way to do that?


Thanks
 
Assuming that you mean after all the nodes have been added, you would have
to do a recursive read of all the nodes and set them to checked = false. I
am sure if you google you will find the recursive code for getting all the
nodes , (I do have a routine to do that but searching for it has not worked
to find that).

If you want to set them to checked = false when you load them, then you must
create a node and set it to unchecked and then add it as you would normally
do.

Lloyd Sheen
 
Here's a little something that ought to get you started....

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

Dim oNode As TreeNode

For Each oNode In TreeView1.Nodes

oNode.Checked = CheckState.Checked

ToggleNodeCheck(oNode, CheckState.Checked)

Next

End Sub

Private Sub ToggleNodeCheck(ByVal Node As TreeNode, ByVal State As
CheckState)

Dim oSubNode As TreeNode

For Each oSubNode In Node.Nodes

oSubNode.Checked = State

ToggleNodeCheck(oSubNode, State)

Next

End Sub
 
Thanks

Lloyd Sheen said:
Assuming that you mean after all the nodes have been added, you would have
to do a recursive read of all the nodes and set them to checked = false.
I am sure if you google you will find the recursive code for getting all
the nodes , (I do have a routine to do that but searching for it has not
worked to find that).

If you want to set them to checked = false when you load them, then you
must create a node and set it to unchecked and then add it as you would
normally do.

Lloyd Sheen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top