Monday, June 6, 2011

asp Tree view custom node coloring


Hi,
I am attempting to set the background color of a treeview node using the following:
Protected Sub TreeView1_PreRender(ByVal sender As Object, ByVal e As EventArgs) Handles TreeView1.PreRender
        For Each node As TreeNode In TreeView1.Nodes
            If node.Text = "Test" Then
                node.ForeColor = System.Drawing.Color.Red
                node.Font.Bold = True
            End If
        Next
End Sub

However, the following error is returned:

 BC30456: 'ForeColor' is not a member of 'System.Web.UI.WebControls.TreeNode'

I have tried searching for an answer, but without success. Any help would be much appreciated.

Thanks.

Edit : The solution will be to set node.Text as a Html , that contains also the color or class that will color the content.

No comments:

Post a Comment