
And populating/adding nodes to custom tree view at runtime.
I am not able to high light (Back color) the selected node in the tree. Im setting the Theme to ControlDefault on my CustomTree view, but this doenst seem to take effect .
Any thoughts how i can high light selected nodes on RAD tree view ? Im extending the controls only for business reason, i didnt modify a thing in their actuall behavior. Or Is there anything specific that i need to do, to get the themes going on a extended RAD Treeview control ?
thanks in advance
Arun
8 Answers, 1 is accepted
Thank you for this question.
When you inherit a control (in this case RadTreeView), you should override the ThemeClassName property. For more information, please refer to the following Knowledge Base article: Inherit themes from RadControls.
If you have additional questions, feel free to contact me.
All the best,
Nikolay
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

Sorry about the reposting, but the search wasnt really helpful.

Hi D,
I updated the Knowledge Base article regarding ThemeClassName with a VB.NET example. As to your scenario where a RadTreeView instance is created runtime, please note that you should call BeginInit/EndInit methods which will apply the theming mechanism:
Imports Telerik.WinControls.UI |
Public Class Form1 |
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load |
Dim tree As RadTreeView = New RadTreeView |
tree.BeginInit() |
tree.Location = New Point(0, 0) |
tree.Size = New Size(100, 500) |
Me.Controls.Add(tree) |
tree.EndInit() |
Dim node As RadTreeNode = New RadTreeNode |
tree.Nodes.Add(node) |
End Sub |
End Class |
If you have additional questions, feel free to contact me.
All the best,
Nikolaythe Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.

Thanks.
The tree nodes are highlighting now. I would appreciate it if you could answer some questions so I understand what is happening. My code is below for reference. I am reading XML files and creating a tree and filling an objecteditpanel with the properties.
1) The tree that I am getting is the Default Control Theme. What if I want the Telerik Theme with nodes that highlight. What would I need to do?
2) I added the override but I am not clear on what is being returned. What is " fullname "?
3) I added BeginInit() and EndInit() and nothing changed. Is it in the correct place? Do I need it? Should I delete BeginInit() and EndInit() ? See my code below.
4) There are several lines of commented code. When I could not get the tree to highlight with the Theme, I put a border around the selected node and saved the level and index. When the next node was selected I put a border around it and tried to remove the border from the previous node by using the level and index of the prior node and changing the border to transparent. I kept getting an error regarding the indexes being outside or negative. However they were exactly what they should have been when I went through the code with breakpoints. I would like to know what I could have done to make it work this way. When I can't get something to work, I try another way. Of course, I won't use this method now that your suggestions have worked but I still want to know what was wrong with the code, if possible.
5) FYI: The RadCustomButtonTestVB file converted with 10 errors so I was not able to look at it.
Code:
Public Class Tree
I
nherits RadTreeView
Public Overrides Property ThemeClassName() As String
Get
Return GetType(RadTreeView).FullName
End Get
Set(ByVal value As String)
End Set
End Property
Private hRecord As NVEAData.Record
Private hObjectEditPanel As ObjectEditPanel
Private vPanel As String = "False"
Private vRecord As String = "False"
Private vNodeSelected As String = "False"
Public Property Record() As NVEAData.Record
'Public vPreviousNodeLevel As Integer = 0
'Public vPreviousNodeIndex As Integer = 0
Get
Return hRecord
End Get
Set(ByVal value As NVEAData.Record)
hRecord = value
If IsNothing(hRecord) Then
Return
End If
BeginInit()
vRecord =
"True"
Nodes.Clear() 'clears tree - otherwise another tree is concatenated to previous tree
Dim Node1 As New RadTreeNode(hRecord.Name) 'Declare Top Node on Tree
Nodes.Add(Node1) 'Add Top Node on Tree
WriteRecordNodes(Node1, hRecord) 'Loads all nodes below the top node
Node1.ExpandAll() 'Expands the entire tree below the top node
LoadRecordIntoEditPanel() 'Load Edit Panel with Top Node
EndInit()
End Set
End Property
Public Property ObjectEditPanel() As ObjectEditPanel
Get
Return hObjectEditPanel
End Get
Set(ByVal value As ObjectEditPanel)
hObjectEditPanel = value
If IsNothing(hObjectEditPanel) Then
Return
Else
vPanel = "True"
LoadRecordIntoEditPanel()
End If
End Set
End Property
Public Sub WriteRecordNodes(ByVal Node As RadTreeNode, ByVal hrecord As Record)
Node.Text = hrecord.Name
Node.Tag = hrecord
For Each c As iRecordCollection In hrecord.Collections
For Each r As Record In c
Dim vnode As New RadTreeNode
Node.Nodes.Add(vnode)
WriteRecordNodes(vnode, r)
Next
Next
End Sub
Public Sub LoadRecordIntoEditPanel()
If vRecord = "True" And vPanel = "True" Then
If vNodeSelected = "True" Then
ObjectEditPanel.Record = CType(SelectedNode.Tag, Record)
'Nodes(vPreviousNodeLevel).Nodes(vPreviousNodeIndex).BorderColor = System.Drawing.Color.Transparent
'SelectedNode.BorderColor = System.Drawing.SystemColors.ActiveBorder
'vPreviousNodeLevel = SelectedNode.Level
'vPreviousNodeIndex = SelectedNode.Index
'MessageBox.Show(vPreviousNodeLevel.ToString & "," & vPreviousNodeIndex.ToString)
Else
ObjectEditPanel.Record = hRecord
End If
End If
End Sub

Thanks again.

Thanks.
The tree nodes are highlighting now. I would appreciate it if you could answer some questions so I understand what is happening. My code is below for reference. I am reading XML files and creating a tree and filling an objecteditpanel with the properties.
1) The tree that I am getting is the Default Control Theme. What if I want the Telerik Theme with nodes that highlight. What would I need to do?
2) I added the override but I am not clear on what is being returned. What is " fullname "?
3) I added BeginInit() and EndInit() and nothing changed. Is it in the correct place? Do I need it? Should I delete BeginInit() and EndInit() ? See my code below.
4) There are several lines of commented code. When I could not get the tree to highlight with the Theme, I put a border around the selected node and saved the level and index. When the next node was selected I put a border around it and tried to remove the border from the previous node by using the level and index of the prior node and changing the border to transparent. I kept getting an error regarding the indexes being outside or negative. However they were exactly what they should have been when I went through the code with breakpoints. I would like to know what I could have done to make it work this way. When I can't get something to work, I try another way. Of course, I won't use this method now that your suggestions have worked but I still want to know what was wrong with the code, if possible.
5) FYI: The RadCustomButtonTestVB file converted with 10 errors so I was not able to look at it.
Code:
Public Class Tree
Inherits RadTreeView
Public Overrides Property ThemeClassName() As String
Get
Return GetType(RadTreeView).FullName
End Get
Set(ByVal value As String)
End Set
End Property
Private hRecord As NVEAData.Record
Private hObjectEditPanel As ObjectEditPanel
Private vPanel As String = "False"
Private vRecord As String = "False"
Private vNodeSelected As String = "False"
Public Property Record() As NVEAData.Record
'Public vPreviousNodeLevel As Integer = 0
'Public vPreviousNodeIndex As Integer = 0
Get
Return hRecord
End Get
Set(ByVal value As NVEAData.Record)
hRecord = value
If IsNothing(hRecord) Then
Return
End If
BeginInit()
vRecord = "True"
Nodes.Clear() 'clears tree - otherwise another tree is concatenated to previous tree
Dim Node1 As New RadTreeNode(hRecord.Name) 'Declare Top Node on Tree
Nodes.Add(Node1) 'Add Top Node on Tree
WriteRecordNodes(Node1, hRecord) 'Loads all nodes below the top node
Node1.ExpandAll() 'Expands the entire tree below the top node
LoadRecordIntoEditPanel() 'Load Edit Panel with Top Node
EndInit()
End Set
End Property
Public Property ObjectEditPanel() As ObjectEditPanel
Get
Return hObjectEditPanel
End Get
Set(ByVal value As ObjectEditPanel)
hObjectEditPanel = value
If IsNothing(hObjectEditPanel) Then
Return
Else
vPanel = "True"
LoadRecordIntoEditPanel()
End If
End Set
End Property
Public Sub WriteRecordNodes(ByVal Node As RadTreeNode, ByVal hrecord As Record)
Node.Text = hrecord.Name
Node.Tag = hrecord
For Each c As iRecordCollection In hrecord.Collections
For Each r As Record In c
Dim vnode As New RadTreeNode
Node.Nodes.Add(vnode)
WriteRecordNodes(vnode, r)
Next
Next
End Sub
Public Sub LoadRecordIntoEditPanel()
If vRecord = "True" And vPanel = "True" Then
If vNodeSelected = "True" Then
ObjectEditPanel.Record = CType(SelectedNode.Tag, Record)
'Nodes(vPreviousNodeLevel).Nodes(vPreviousNodeIndex).BorderColor = System.Drawing.Color.Transparent
'SelectedNode.BorderColor = System.Drawing.SystemColors.ActiveBorder
'vPreviousNodeLevel = SelectedNode.Level
'vPreviousNodeIndex = SelectedNode.Index
'MessageBox.Show(vPreviousNodeLevel.ToString & "," & vPreviousNodeIndex.ToString)
Else
ObjectEditPanel.Record = hRecord
End If
End If
End Sub
Please find the answers to your questions below:
- If you want to use the Telerik theme, you should drag and drop the TelerikTheme component on the form. Then, you should set the ThemeName property of the RadTreeView instance to Telerik.
- The FullName returns the fully qualified name of the Type, including its namespace. So, for RadTreeView the FullName is Telerik.WinControls.UI.RadTreeView. For additional information, refer to MSDN.
- You should call BeginInIt/EndInIt for the runtime created instances of your RadTreeView. You should not use them in the class that inherits RadTreeView class.
- Please find the answer to this question in your support ticket about the same topic.
- Most probably you do not have the latest version Q3 2008 SP2 (v8.2.0.0) and therefore you are getting the compile errors. Please update your version to the latest one and try again.
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.