Camillia
asked on
Make treeview node bold
I have a treeview that i've defined in my Master page. I build the treeview dynamically in the whatever.aspx.
Tree looks like this:
>node1
>node2
>node3
>subnode3_1
>subnode3_2
I want to the fonts for the main nodes to be bold. I tried these :
1. Font-Bold="true" makes nodes and SUBnodes bold
2. RootNodeStyle-Font-Bold="t rue" : makes "node3" bold BUT doesnt makde node1 and node2 bold. It should since they're main nodes too..no?
3. NodeStyle-Font-Bold="true" : i think it made all of the nodes and subnodes bold
Tried a combination and didnt work. Wanted to do it dynamically in the code behind but i didnt see "attributes" for the treenode:
treeNode = New TreeNode(....)
Tree looks like this:
>node1
>node2
>node3
>subnode3_1
>subnode3_2
I want to the fonts for the main nodes to be bold. I tried these :
1. Font-Bold="true" makes nodes and SUBnodes bold
2. RootNodeStyle-Font-Bold="t
3. NodeStyle-Font-Bold="true"
Tried a combination and didnt work. Wanted to do it dynamically in the code behind but i didnt see "attributes" for the treenode:
treeNode = New TreeNode(....)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hmmm...this isnt working...
1. I imported : Imorts System.Drawing
2. I cant do what Jaime has because I cant have "New Font (Treeview1.Font,Font.Bold) ". New Font cant take "treeview1.Font" as one of the parameters. It has to be a font family name.
I looked at emoreau's example and tried webTubbs's example as well but I dont see .BackColor or .NodeFont.
I tried this : http://www.vb-helper.com/howto_net_font_samples.html
and created a new font: Dim new_font As New Font("Something", 8, FontStyle.Bold)
**But now what..I have the treeNode like this:
treeNode = New TreeNode("whatever")
But I dont know how to assign the font to the treeNode. I did " treenode. " but I dont see a Font or "Something" in intellisense...
1. I imported : Imorts System.Drawing
2. I cant do what Jaime has because I cant have "New Font (Treeview1.Font,Font.Bold)
I looked at emoreau's example and tried webTubbs's example as well but I dont see .BackColor or .NodeFont.
I tried this : http://www.vb-helper.com/howto_net_font_samples.html
and created a new font: Dim new_font As New Font("Something", 8, FontStyle.Bold)
**But now what..I have the treeNode like this:
treeNode = New TreeNode("whatever")
But I dont know how to assign the font to the treeNode. I did " treenode. " but I dont see a Font or "Something" in intellisense...
>>I looked at emoreau's example and tried webTubbs's example as well but I dont see .BackColor or .NodeFont.
Are you working with Compact Framework / Windows Mobile ?
Are you working with Compact Framework / Windows Mobile ?
ASKER
no, this is asp.net/VB.net (not my forms C# app).
This is what I have so far...
This is what I have so far...
Dim treeNode As TreeNode
Dim treeSubNode As TreeNode
Dim treeSubNode2 As TreeNode
Dim da As DataRow
Dim daNode As DataRow
' Dim p As FontStyle = FontStyle.Bold
Dim new_font As New Font("Something", 8, FontStyle.Bold)
If userTabsTable.Rows.Count > 0 Then 'if user has tabs setup in taborder table.
'build the nodes. Localize node text
For Each da In userTabsTable.Rows
treeNode = New TreeNode(...)
....
ASKER
And I have VS2005, Professional Edtion.
This works Master.tvTabsms.Font.Bold = True
But that makes ALL the nodes, even the subnodes bold/
This works Master.tvTabsms.Font.Bold = True
But that makes ALL the nodes, even the subnodes bold/
ASKER
Now I see it:
With (Master.mytreeview)
End With
I was doing : with (master.mytreeview.nodes)
End With
Let me play around with it and see how I can use that with my "treeNode" variable
With (Master.mytreeview)
End With
I was doing : with (master.mytreeview.nodes)
End With
Let me play around with it and see how I can use that with my "treeNode" variable
ASKER
No, I cant get this to work. Even tried following Eric's example but I get "expression does not produce a value".
This cant be that hard!
This cant be that hard!
With Master.tvTabsms
If userTabsTable.Rows.Count > 0 Then 'if user has tabs setup in taborder table.
'build the nodes. Localize node text
For Each da In userTabsTable.Rows
treeNode = New TreeNode(CStr(HttpContext.GetLocalResourceObject("/SideMenuTree", "tv" & da(1).ToString.Trim & ".Text")))
Dim nodeParent As TreeNode
nodeParent = Master.tvTabsms.Nodes.Add(New TreeNode(CStr(HttpContext.GetLocalResourceObject("/SideMenuTree", "tv" & da(1).ToString.Trim & ".Text")))) '**** get an error here
If da(2).ToString.Trim = "X" OrElse da(2).ToString.Trim = "XX" Then 'build the subnode
For Each daNode In userTabsSubNodeTable.Rows
treeSubNode = New TreeNode(daNode(0).ToString)
treeNode.ChildNodes.Add(treeSubNode)
If da(2).ToString.Trim = "XX" And daNode(1).ToString.Trim <> String.Empty Then
treeSubNode2 = New TreeNode(daNode(1).ToString)
treeSubNode.ChildNodes.Add(treeSubNode2)
End If
Next
Master.tvTabsms.Nodes.Add(treeNode)
Else
' treeNode = New TreeNode(CStr(HttpContext.GetLocalResourceObject("/SideMenuTree", "tv" & da(1).ToString.Trim & ".Text")))
Master.tvTabsms.Nodes.Add(treeNode)
End If
Next
End If
End With
ASKER
ASKER
If I do this, I can get the main nodes to change color to Red:
treeNode = New TreeNode("<font color = red>" & CStr(HttpContext.GetLocalR esourceObj ect("/Side MenuTree", "tv" & da(1).ToString.Trim & ".Text")) & "</font>")
I found it here: http://forums.devx.com/showthread.php?t=153246
Now need to make it bold
treeNode = New TreeNode("<font color = red>" & CStr(HttpContext.GetLocalR
I found it here: http://forums.devx.com/showthread.php?t=153246
Now need to make it bold
ASKER
Sorry everyone, I made it work like this:
treeNode = New TreeNode("<b>" & CStr(HttpContext.GetLocalR esourceObj ect("/Side MenuTree", "tv" & da(1).ToString.Trim & ".Text")) & "</b>")
Thanks
treeNode = New TreeNode("<b>" & CStr(HttpContext.GetLocalR
Thanks
ASKER