Hi,
In my project i am loading treeview with employee name's at the runtime.In default i am applying the skin "INOX" to the treeview.But at the runtime for the specific condition i need to change the particular nodetext color to red and also the font size to be bold for that particular nodetext.
How can i do this? I want to do this on server side ......
help me immediately..............
Regards,
Giri..............
In my project i am loading treeview with employee name's at the runtime.In default i am applying the skin "INOX" to the treeview.But at the runtime for the specific condition i need to change the particular nodetext color to red and also the font size to be bold for that particular nodetext.
How can i do this? I want to do this on server side ......
help me immediately..............
Regards,
Giri..............
5 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 25 Nov 2008, 08:00 AM
Hello Giri,
You can try setting the forecolor and font of the node as shown in the code snippet below:
aspx:
cs:
Thanks
Princy.
You can try setting the forecolor and font of the node as shown in the code snippet below:
aspx:
<telerik:RadTreeView ID="RadTreeView1" Skin="Inox" runat="server" OnNodeDataBound="RadTreeView1_NodeDataBound" OnPreRender="RadTreeView1_PreRender"> |
<Nodes> |
<telerik:RadTreeNode Text="Node1"> |
<Nodes> |
<telerik:RadTreeNode Text="SubNode11"></telerik:RadTreeNode> |
<telerik:RadTreeNode Text="SubNode12"></telerik:RadTreeNode> |
<telerik:RadTreeNode Text="SubNode13"></telerik:RadTreeNode> |
</Nodes> |
</telerik:RadTreeNode> |
<telerik:RadTreeNode Text="Node2"> |
<Nodes> |
<telerik:RadTreeNode Text="SubNode21"></telerik:RadTreeNode> |
<telerik:RadTreeNode Text="SubNode22"></telerik:RadTreeNode> |
<telerik:RadTreeNode Text="SubNode23"></telerik:RadTreeNode> |
</Nodes> |
</telerik:RadTreeNode> |
</Nodes> |
</telerik:RadTreeView> |
cs:
protected void RadTreeView1_PreRender(object sender, EventArgs e) |
{ |
foreach (RadTreeNode node in RadTreeView1.Nodes) |
{ |
if (node.Text == "Node1") |
{ |
node.ForeColor = System.Drawing.Color.Red; |
node.Font.Bold = true; |
} |
} |
} |
Thanks
Princy.
0

Jill-Connie Lorentsen
Top achievements
Rank 1
answered on 01 Apr 2009, 12:29 PM
I've also tried to do this, but I get an error saying that node.Font.Bold and node.Font.Italic is readonly?
I've also tried the following:
I've also tried the following:
Font
myfont = new Font(node.Font, FontStyle.Italic);
node.Font = myfont;
Then I get an exception saying that node.Font = null
What am I missing?
Regards, Jill-Connie Lorentsen
0
Hello Jill-Connie Lorentsen,
Here is the code I used which worked just fine:
This made the text of all my root nodes to be Bold and Italic.
What is different in your case?
Sincerely yours,
Veselin Vasilev
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Here is the code I used which worked just fine:
<telerik:RadTreeView ID="RadTreeView1" runat="server" Skin="Vista"> |
<Nodes> |
<telerik:RadTreeNode runat="server" Text="Root RadTreeNode1"> |
<Nodes> |
<telerik:RadTreeNode runat="server" Text="Child RadTreeNode 1"> |
</telerik:RadTreeNode> |
<telerik:RadTreeNode runat="server" Text="Child RadTreeNode 2"> |
</telerik:RadTreeNode> |
</Nodes> |
</telerik:RadTreeNode> |
<telerik:RadTreeNode runat="server" Text="Root RadTreeNode2"> |
<Nodes> |
<telerik:RadTreeNode runat="server" Text="Child RadTreeNode 1"> |
</telerik:RadTreeNode> |
<telerik:RadTreeNode runat="server" Text="Child RadTreeNode 2"> |
</telerik:RadTreeNode> |
</Nodes> |
</telerik:RadTreeNode> |
<telerik:RadTreeNode runat="server" Text="Root RadTreeNode3"> |
<Nodes> |
<telerik:RadTreeNode runat="server" Text="Child RadTreeNode 1"> |
</telerik:RadTreeNode> |
</Nodes> |
</telerik:RadTreeNode> |
</Nodes> |
</telerik:RadTreeView> |
protected void Page_Load(object sender, EventArgs e) |
{ |
foreach (RadTreeNode node in RadTreeView1.Nodes) |
{ |
node.Font.Bold = true; |
node.Font.Italic = true; |
} |
} |
This made the text of all my root nodes to be Bold and Italic.
What is different in your case?
Sincerely yours,
Veselin Vasilev
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0

Jill-Connie Lorentsen
Top achievements
Rank 1
answered on 02 Apr 2009, 08:15 AM
Nothing is different, - and I still get the message that the property is invalid.
I've worked around the problem, and I now use the font of the tree view as a starting point, and it works fine.
I've worked around the problem, and I now use the font of the tree view as a starting point, and it works fine.
Font myfont = new Font(radTreeView.Font, FontStyle.Italic);
node.Font = myfont;
0

Trevor
Top achievements
Rank 2
answered on 14 May 2009, 03:17 PM
Can I set the font size color and more importantly Bold when using an xml file.
I am able to set the following:
I am able to set the following:
Text
ImageUrl
Expanded
NavigateUrl
But I am unable to set the font.
ie.
<Contracts Text="Contract #102" ImageUrl="~/TreeView/drafts.gif" Expanded="True"/ NavigateUrl="home.aspx"/>
<Contracts Text="Contract #103" ImageUrl="~/TreeView/drafts.gif" Expanded="True"/>
Please advise.