Groups | Blog | Home
all groups > vb.net > february 2007 >

vb.net : Make Treeview Node Font Bold


Lloyd Sheen
2/18/2007 5:03:48 PM
The return value of ....Item(i) is a TreeViewNode. That object does not
have a font property. I think if you want to make them visually different
you could use the Backcolour / ForeColor or make the control a userpaint
DrawMode = OwnerDrawText . I have not tried the latter but I am sure you
can find examples on the web.

Lloyd Sheen

[quoted text, click to view]
Ben
2/18/2007 7:33:58 PM
Hi

I am having problems making a single node's Font Bold.

objUserTree.Nodes.Item(i)


I am looping though the items but with every property I try it fails.

Thanks
B

Phill W.
2/19/2007 12:56:35 PM
[quoted text, click to view]

The TreeNode class sports a NodeFont property (of Type [Font]), but you
can't set individual properties on it; you have to create a whole new
Font object and replace the existing one, as in :

With objUserTree.Nodes.Item(i)
.NodeFont = New Font( .NodeFont, FontStyle.Bold )
End With

You might want to build this "boldFont" object [once] and store it
somewhere, rather than recreating it every time you want to make a Node
bold.

HTH,
AddThis Social Bookmark Button