Force not check some checkbox in TriStateMode.

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

    Posted 21 Dec 2010 Link to this post

    I want to prevent some nodes to check by some condition (let's say that is node.Enabled in this case - actually it can be more complicated).
    Also I want to use TriStateMode to simplify process of control node's check state and (mainly) make visible to user that some lower nodes in tree are not checked.

    In this example, nodes "Not checkable" could not be checked. And, if I check root node "Main node" - this example works fine. But when I change "block 1" and "block 2" and try to check root node - it don't. Event fired for node "Not Checkable node", invert it, return to root node and uncheck it.

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        RadTreeView1.TriStateMode = True
        RadTreeView1.AutoCheckChildNodes = True
        Dim mainNode As Telerik.WinControls.UI.RadTreeNode
        Dim newNode As Telerik.WinControls.UI.RadTreeNode
        Dim newSubNode As Telerik.WinControls.UI.RadTreeNode
        mainNode = New Telerik.WinControls.UI.RadTreeNode("Main node")
        mainNode.Enabled = True
        ' block 1 - start
        newNode = New Telerik.WinControls.UI.RadTreeNode("Checkable node")
        newNode.Enabled = True
        newSubNode = New Telerik.WinControls.UI.RadTreeNode("Checkable node 1")
        newSubNode.Enabled = True
        ' block 1 - end
        ' block 2 - start
        newNode = New Telerik.WinControls.UI.RadTreeNode("Not Checkable node")
        newNode.Enabled = False
        newSubNode = New Telerik.WinControls.UI.RadTreeNode("Not Checkable node 1")
        newSubNode.Enabled = False
        ' block 2 - end
    End Sub
    Private Sub RadTreeView1_NodeCheckedChanged(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.RadTreeViewEventArgs) Handles RadTreeView1.NodeCheckedChanged
        If e.Node.Checked AndAlso Not e.Node.Enabled Then
            e.Node.Checked = False
        End If
    End Sub

    I am using Telerik version=2010.1.10.308

    Another question: How can I maintain view of checkbox in TriStateMode? I mean that "grey sign" instead of "black sign" is not so obvious for user - I would prefer to change color or something like that. May be there is another method to control/theming checkbox? If it's possible, I would not use TriState and maintain checkboxes state (and checkbox representation) manually in code.
  2. Julian Benkov
    Julian Benkov avatar
    1135 posts

    Posted 27 Dec 2010 Link to this post

    Hello Peter Bogoyavlensky,

    I tested the described case using our latest release and could not observe any issue related with the tree state mode and disabled state in RadTreeView. Please, could you confirm that you are using our latest release. If the issue continues to appear, please send us a sample project which reproduces the issue and describe the exact steps. Thank you in advance for your understanding and cooperation.

    I am looking forward to your reply.

    Greetings, Julian Benkov
    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
  3. DevCraft R3 2016 release webinar banner
  4. Stefan
    Stefan avatar
    2891 posts

    Posted 18 Mar 2011 Link to this post

    Hello Peter,

    Please note that in Q1 2011 we have introduced a major upgrade of RadTreeView control, which is now virtualized and fully customizable. Feel free to download the latest release and try it out. For more information on our latest release, please refer to this blog post.
    Best wishes,
    the Telerik team
Back to Top