Controlling Autocheck Child Nodes

3 posts, 0 answers
  1. Doug
    Doug avatar
    50 posts
    Member since:
    Jul 2012

    Posted 23 Oct 2012 Link to this post

    I'm using TriStateMode = true and AutoCheckChildNodes = true.  I would like to keep the behavior that checking a node automatically checks all children.  But if I uncheck all the children, the parent node also unchecks.  I would like to leave the parent node either checked or indeterminate (and possibly change the indeterminate image).

    Even better, is it possible to modify this behavior for some parent nodes but not for other parent nodes?

    Thank you,
  2. Doug
    Doug avatar
    50 posts
    Member since:
    Jul 2012

    Posted 24 Oct 2012 Link to this post

    I got it working well enough so far.  This will leave a parent node checkstate = indeterminate when the last of the child nodes is unchecked.  Otherwise, the checkstate changes follow the default behavior.  I'm not working in C# on this project yet, this is ASNA's Visual RPG.  You'll be able to translate it.  StopParentUncheck is a boolean variable.  "Begsr" are methods that return nothing.  trvPermissions is a RadTreeView.

        BegSr trvPermissions_SelectedNodeChanged Access(*Private) Event(*this.trvPermissions.SelectedNodeChanged)

            DclSrParm sender *Object

            DclSrParm e Telerik.WinControls.UI.RadTreeViewEventArgs


            StopParentUncheck = *False




        BegSr trvPermissions_NodeCheckedChanging Access(*Private)

            DclSrParm sender *Object

            DclSrParm e Telerik.WinControls.UI.RadTreeViewCancelEventArgs


            If trvPermissions.SelectedNode = *Nothing   





                When e.Node.Checked and ( e.Node = trvPermissions.SelectedNode ) and ( e.Node.Level > 0 )

                    StopParentUncheck = NOT SiblingsSelected( trvPermissions.SelectedNode )


                When ( e.Node = trvPermissions.SelectedNode.Parent )

                    e.Cancel = StopParentUncheck





        BegFunc SiblingsSelected Type( *Boolean )

            DclSrParm TheNode Type( RadTreeNode )


            DclFld SiblingNode Type( RadTreeNode )


            If TheNode.Parent = *Nothing

                Leavesr Value( *False )



            ForEach SiblingNode Collection( TheNode.Parent.Nodes )

                If ( SiblingNode <> TheNode ) and SiblingNode.Checked

                    Leavesr Value( *True )




            Leavesr Value( *False )




  3. DevCraft banner
  4. Stefan
    Stefan avatar
    2891 posts

    Posted 26 Oct 2012 Link to this post

    Hello Gary,

    I am glad to hear that you have found a solution for this case. 

    Another approach that comes to my mind is to turn off the AutoCheckChildNodes and the TriStateMode and handle all checks in the NodeCheckedChagned event.
    the Telerik team
    Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
Back to Top