Completed
Last Updated: 06 Nov 2014 09:04 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 28 Jul 2014 11:58
Category: TreeView
Type: Bug Report
0
FIX. RadTreeView - No scroll bars are displayed after expanding a RadTreeNode
To reproduce: add a hierarchical RadTreeView with several levels. Use the  RadTreeNode.Expanded property in order to expand a child node from the bottom levels. Ensure that all parent nodes up to the top are expanded as well. When you run the application, the vertical scroll bar is not displayed.

Sub New()
    InitializeComponent()
    Me.Size = New Size(234, 188)
    Dim dt As New DataTable
    dt.Columns.Add("Id", GetType(String))
    dt.Columns.Add("ParentId", GetType(String))
    dt.Columns.Add("Name", GetType(String))

    Dim uniqueId As String = Guid.NewGuid().ToString()
    dt.Rows.Add(uniqueId, Nothing, "Node.1")
    For index = 2 To 5
        Dim subUniqueId As String = Guid.NewGuid().ToString()
        dt.Rows.Add(subUniqueId, uniqueId, "SubNode.1." & index)
        If index Mod 2 = 0 Then
            For index2 = 6 * index To 6 * index + 5
                Dim subSubUniqueId As String = Guid.NewGuid().ToString()
                dt.Rows.Add(subSubUniqueId, subUniqueId, "SubSubNode.1." & index & "." & index2)
                For index3 = 12 * index To 12 * index + 3
                    Dim subSubSubUniqueId As String = Guid.NewGuid().ToString()
                    dt.Rows.Add(subSubSubUniqueId, subSubUniqueId, "SubSubSubNode.1." & index & "." & index2 & "." & index3)
                Next
            Next
        End If
    Next

    Me.RadTreeView1.DataSource = dt
    Me.RadTreeView1.DisplayMember = "Name"
    Me.RadTreeView1.ValueMember = "Id"
    Me.RadTreeView1.RelationBindings.Add(New RelationBinding(dt, "Name", "ParentId", "Id", "Id"))

End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim nodeTextToExpand = "SubSubNode.1.4.27"
    Dim nodeToExpand = Me.RadTreeView1.GetNodeByName(nodeTextToExpand)
    If nodeToExpand IsNot Nothing Then
        Expand(nodeToExpand)
    End If
End Sub

Private Sub Expand(nodeToExpand As RadTreeNode)
    nodeToExpand.Expanded = True
    If nodeToExpand.Parent IsNot Nothing Then
        Expand(nodeToExpand.Parent)
    End If
End Sub

Workaround: start expanding the nodes from the top most level to the bottom most level: 
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim nodeTextToExpand = "SubSubNode.1.4.27"
    Dim nodeToExpand = Me.RadTreeView1.GetNodeByName(nodeTextToExpand)
    If nodeToExpand IsNot Nothing Then
        Expand(nodeToExpand)
    End If

    While (nodes.Count > 0)
        nodes.Pop().Expanded = True
    End While
End Sub

Dim nodes As New Stack(Of RadTreeNode)
Private Sub Expand(nodeToExpand As RadTreeNode)       
    nodes.Push(nodeToExpand)
    If nodeToExpand.Parent IsNot Nothing Then
        Expand(nodeToExpand.Parent)
    End If
End Sub
Attached Files:
0 comments