Is there a way to set readonly to checkboxes within the treeview

3 posts, 1 answers
  1. Dean Marriott
    Dean Marriott avatar
    17 posts
    Member since:
    May 2007

    Posted 20 Dec 2010 Link to this post

    Hi,

    Is there a way to set readonly to checkboxes within the treeview?

    There is an Enabled property that will give me a similar effect I want however it does also disable the scrollbar access, which the screen view cannot be scroll to up or down.

    Can you help? Many thanks in advance.

  2. Answer
    Dean
    Dean avatar
    43 posts
    Member since:
    Jun 2009

    Posted 21 Dec 2010 Link to this post

    Hi Dean,

    I've created some quick sample code to show you how you can disable a node, In the example it will disable all nodes that are currently checked and enable all nodes that are not checked. Hope this helps you. Just add a RadTreeView Control onto a Form and add the below code.

    Imports Telerik.WinControls.UI
     
    Public Class Form1
        Private m_bChecked As Boolean
        Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            RadTreeView1.CheckBoxes = True
            RadTreeView1.Size = New Size(250, 250)
            BuildNodeList()
            For Each oNode In RadTreeView1.Nodes
                oNode.Enabled = Not oNode.Checked
                For Each oChildNode In oNode.Nodes
                    oChildNode.Enabled = Not oChildNode.Checked
                Next
            Next
        End Sub
     
        Private Sub BuildNodeList()
            Dim ParentNode As RadTreeNode
            Dim ChildNode As RadTreeNode
            For i = 0 To 100
                ParentNode = New RadTreeNode("ParentNode" & i.ToString)
                ParentNode.ShowCheckBox = True
                ParentNode.Checked = m_bChecked
                For x = 0 To 13
                    ChildNode = New RadTreeNode("ChildNode" & x.ToString)
                    ChildNode.Checked = m_bChecked
                    ChildNode.ShowCheckBox = True
                    ParentNode.Nodes.Insert(x, ChildNode)
                    m_bChecked = Not m_bChecked
                Next
                RadTreeView1.Nodes.Insert(i, ParentNode)
                m_bChecked = Not m_bChecked
            Next
        End Sub
     
    End Class
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Dean Marriott
    Dean Marriott avatar
    17 posts
    Member since:
    May 2007

    Posted 21 Dec 2010 Link to this post

    Thanks very much Dean, this works exactly how I wanted. 
Back to Top