This is a migrated thread and some comments may be shown as answers.

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

2 Answers 377 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Dean Marriott
Top achievements
Rank 1
Dean Marriott asked on 21 Dec 2010, 05:18 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Dean
Top achievements
Rank 2
answered on 21 Dec 2010, 07:31 AM
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
0
Dean Marriott
Top achievements
Rank 1
answered on 21 Dec 2010, 08:12 AM
Thanks very much Dean, this works exactly how I wanted. 
Tags
Treeview
Asked by
Dean Marriott
Top achievements
Rank 1
Answers by
Dean
Top achievements
Rank 2
Dean Marriott
Top achievements
Rank 1
Share this question
or