Hello

I have a TreeView such as this

1
2
2a
2b
3
4
4a
5

And I want to when I press a button disable 2 and 4 (with all its child nodes). How can I do this?

Thanks

Hi,

You can try it this way:

Private Sub TreeView1_AfterCheck(ByVal sender As Object, ByVal e As Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterCheck
 
If TreeView1.Nodes.Item(0).Nodes.Item(0).Checked = False Then
 
TreeView1.Nodes.Item(0).Nodes.Item(0).Checked = True
 
End If
 
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.