Node in TriState mode get wrong CheckState.

2 posts, 0 answers
  1. Peter Bogoyavlensky
    Peter Bogoyavlensky avatar
    20 posts
    Member since:
    Feb 2009

    Posted 17 May 2012 Link to this post

    I use Telerik Version=2011.3.11.1219 and try use TreeView control with TriStateMode.

    Question 1: Also I want to prevent checking node due some conditions - for example, if node.ImageKey ="class_grey" (some picture from imagelist container).

    Private Sub RadTreeView1_NodeCheckedChanging(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.RadTreeViewCancelEventArgs) Handles RadTreeView1.NodeCheckedChanging
      If Not e.Node.Checked AndAlso e.Node.ImageKey = "class_grey" Then
        e.Cancel = True
      End If
    End Sub

    If I make that tree:
    and try to check node "Node1" - I get this situation:

    But it is obviously wrong! Nodes "Node1" and "Node8" have wrong state mode ("On" instead of "Indeterminate")
    It should be like that (which I got if uncheck/check node "Node9"):

    How can I fix that?

    Question 2: How can I change view of checkbox in TriState mode? For example, I would like to change view for "Indeterminate" mode from filled green box to red tick.
  2. Svett
    Svett avatar
    728 posts

    Posted 21 May 2012 Link to this post

    Hi Peter,

    Thank you for writing.

    I managed to reproduce the issue. I logged it in PITS and it will be addressed in one of the next releases. Here is a link to the item, where you can add your vote for it, in order to increase its priority: 

    Meanwhile, you should use the NodeCheckedChanging and NodeCheckedChanged event to work around it:
    int checkingCount = 0;
    private void OnNodeCheckedChanging(object sender, RadTreeViewCancelEventArgs e)
        if (e.Node.Tag != null)
            e.Cancel = true;
    private void OnNodeCheckedChanged(object sender, RadTreeViewEventArgs e)
        if (this.checkingCount == 0)
    private void CorrentParentStates(RadTreeNode radTreeNode)
        Stack<RadTreeNode> invalidParents = new Stack<RadTreeNode>();
        Stack<RadTreeNode> childNodes = new Stack<RadTreeNode>();
        FieldInfo fieldInfo = typeof(RadTreeNode).GetField("checkState", BindingFlags.NonPublic | BindingFlags.Instance);
        while (childNodes.Count > 0)
            RadTreeNode currentNode = childNodes.Pop();
            RadTreeNodeCollection nodes = currentNode.Nodes;
            foreach (RadTreeNode node in nodes)
                if (node.CheckState != currentNode.CheckState && !invalidParents.Contains(currentNode))
                if (node.Nodes.Count > 0)
        foreach (RadTreeNode node in invalidParents)
            RadTreeNode parent = node;
            while (parent != null)
                fieldInfo.SetValue(parent, ToggleState.Indeterminate);
                parent = parent.Parent;

    You can use the Visual Style Builder tool in order to to change the visual representation of the intermediate state of the check box for a specific theme. In addition, you should change the visual states for mouse over and pressed. You can read more about how you can use Visual Style Builder in the online documentation. Also, attached you can find a screenshot that presents the visual states that you should modify.

    I hope this helps. Your Telerik points have been updated for this report.

    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top