Make Treeview Node Font Bold

B

Ben

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
 
L

Lloyd Sheen

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
 
P

Phill W.

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

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,
Phill W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top