Troube adding custom nodes to treeview

2 posts, 0 answers
  1. Scott
    Scott avatar
    6 posts
    Member since:
    Oct 2018

    Posted 30 Oct 2018 Link to this post

    Hi,

    I'm able to get the samples to work but I'm having trouble adding to my project. It seems that TreeViewElement_CreateNodeElement isn't firing.

    Can anyone see what I might be missing? The code below just needs a radtreeview named tvProjectPath.

    Thanks in advance!!

    Imports Telerik.WinControls.UI
     
    Public Class RadForm1
        Private Sub RadForm1_Load(sender As Object, e As EventArgs) Handles Me.Load
            Dim rtvTest As Telerik.WinControls.UI.RadTreeView = tvProjectPath
            Dim DFSRootNode As New RadTreeNode("Root0")
            Dim ProdDataNode As New RadTreeNode("Child1")
            Dim JobsNode As New RadTreeNode("Child2")
            Dim ProjectRoot As New RadTreeNode("Child3")
            'Dim ProjectFolder As New CustomTreeNodeElement()
            tvProjectPath.Nodes.Add(DFSRootNode)
            DFSRootNode.Nodes.Add(ProdDataNode)
            ProdDataNode.Nodes.Add(JobsNode)
            JobsNode.Nodes.Add(ProjectRoot)
            'ProjectRoot.TreeViewElement =
        End Sub
        Private Sub CustomNodes_Load(sender As Object, e As EventArgs) Handles Me.Load
            Dim test As String = ""
     
            Me.tvProjectPath.ExpandAll()
        End Sub
        Private Sub TreeViewElement_CreateNodeElement(sender As Object, e As Telerik.WinControls.UI.CreateTreeNodeElementEventArgs)
            e.NodeElement = New CustomTreeNodeElement()
        End Sub
    End Class
    Public Class CustomContentElement
        Inherits TreeNodeContentElement
        Private nodeContentContainer As StackLayoutElement
        Private nodeLabel As RadLabelElement
        Private nodeTextBox As RadTextBoxControlElement
     
        Protected Overrides ReadOnly Property ThemeEffectiveType() As Type
            Get
                Return GetType(TreeNodeElement)
            End Get
        End Property
        Protected Overrides Sub InitializeFields()
            MyBase.InitializeFields()
            Me.StretchHorizontally = True
        End Sub
        Protected Overrides Sub CreateChildElements()
            MyBase.CreateChildElements()
            nodeContentContainer = New StackLayoutElement
            nodeContentContainer.Orientation = Orientation.Horizontal
            nodeContentContainer.StretchHorizontally = True
            nodeContentContainer.StretchVertically = False
            nodeLabel = New RadLabelElement
            Me.Children.Add(nodeLabel)
            nodeTextBox = New RadTextBoxControlElement
            Me.Children.Add(nodeTextBox)
     
        End Sub
     
    End Class
    Public Class CustomTreeNodeElement
        Inherits TreeNodeElement
        Protected Overrides Function CreateContentElement() As TreeNodeContentElement
            Return New CustomContentElement()
            'Dim node As RadTreeNode = Me.Data
     
        End Function
     
        Protected Overrides ReadOnly Property ThemeEffectiveType() As Type
            Get
                Return GetType(TreeNodeElement)
            End Get
        End Property
     
    End Class

  2. Dimitar
    Admin
    Dimitar avatar
    2918 posts

    Posted 31 Oct 2018 Link to this post

    Hi Scott,

    The Handles part is missing:
    Private Sub RadTreeView1_CreateNodeElement(sender As Object, e As Telerik.WinControls.UI.CreateTreeNodeElementEventArgs) Handles RadTreeView1.CreateNodeElement
     
        End Sub

    I hope this will be useful. Let me know if you have additional questions.

    Regards,
    Dimitar
    Progress Telerik
    Get quickly onboard and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top