Treeview Checkboxes

  • Thread starter Thread starter jamesdorringtonuk
  • Start date Start date
J

jamesdorringtonuk

Hi, I have a checkbox treeview control in a form, but currently, if
you check a root node (or any node for that matter) it does not
automatically check the sub-nodes. Is there a setting on the control
that I need to use to make this behaviour default or do I need to
manually check all subnodes myself, perhaps on the AfterCheck event?

Many TIA
 
Hi, I have a checkbox treeview control in a form, but currently, if
you check a root node (or any node for that matter) it does not
automatically check the sub-nodes. Is there a setting on the control
that I need to use to make this behaviour default or do I need to
manually check all subnodes myself, perhaps on the AfterCheck event?

Untested:

\\\
Private Sub TreeView1_AfterCheck( _
ByVal sender As Object, _
ByVal e As TreeViewEventArgs _
) Handles TreeView1.AfterCheck
e.Node.CheckSubNodes(e.Node.Checked)
End Sub
....
Public Module TreeeViewExtensions
<Extension()> _
Public Sub CheckSubNodes( _
ByVal Node As TreeNode, ByVal Checked As Boolean _
)
For Each SubNode As TreeNode In Node.Nodes
SubNode.Checked = Checked
CheckSubNodes(SubNode, Checked)
Next SubNode
End Sub
End Module
///
 
Hi, I have a checkbox treeview control in a form, but currently, if
you check a root node (or any node for that matter) it does not
automatically check the sub-nodes. Is there a setting on the control
that I need to use to make this behaviour default or do I need to
manually check all subnodes myself, perhaps on the AfterCheck event?

Untested:

\\\
Private Sub TreeView1_AfterCheck( _
ByVal sender As Object, _
ByVal e As TreeViewEventArgs _
) Handles TreeView1.AfterCheck
e.Node.CheckSubNodes(e.Node.Checked)
End Sub
....
Public Module TreeeViewExtensions
<Extension()> _
Public Sub CheckSubNodes( _
ByVal Node As TreeNode, ByVal Checked As Boolean _
)
For Each SubNode As TreeNode In Node.Nodes
SubNode.Checked = Checked
CheckSubNodes(SubNode, Checked)
Next SubNode
End Sub
End Module
///
 
Back
Top