Hi.
Is it possible to set the CheckState of a parent node independently of how the child nodes are set? In my code, it won't let me change the state if there are different states in child node.
Here's the code, just a simple form with a RadTreeView named "tree" on it:
Imports Telerik.WinControls
Imports Telerik.WinControls.UI
Public Class frmTest
Private Sub frmTest_Load(sender As Object, e As EventArgs) Handles Me.Load
Me.tree.CheckBoxes = True
Me.tree.AutoCheckChildNodes = False
Me.tree.TriStateMode = True
For i As Integer = 1 To 2
Dim node As New RadTreeNode("Parent " + i.ToString)
Me.tree.Nodes.Add(node)
For j As Integer = 1 To 3
node.Nodes.Add("Child " + j.ToString)
Next
Next
Me.tree.ExpandAll()
End Sub
Private Sub tree_NodeMouseClick(sender As Object, e As RadTreeViewMouseEventArgs) Handles tree.NodeMouseClick
e.Node.Current = True
Select Case e.Node.CheckState
Case Enumerations.ToggleState.On
e.Node.CheckState = Enumerations.ToggleState.Off
Case Enumerations.ToggleState.Off
e.Node.CheckState = Enumerations.ToggleState.Indeterminate
Case Enumerations.ToggleState.Indeterminate
'won't change the state on a parent node if not all child nodes are checked!
e.Node.CheckState = Enumerations.ToggleState.On
End Select
e.Node.Current = False
End Sub
Private Sub tree_NodeCheckedChanging(sender As Object, e As RadTreeViewCancelEventArgs) Handles tree.NodeCheckedChanging
If Not e.Node.Current Then
e.Cancel = True
End If
End Sub
End Class
I hope that makes sense..