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

Troube adding custom nodes to treeview

1 Answer 89 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 31 Oct 2018, 12:03 AM

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

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 31 Oct 2018, 10:46 AM
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.
Tags
Treeview
Asked by
Scott
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or