Make Treeview Node Font Bold

Discussion in 'Microsoft VB .NET' started by Ben, Feb 18, 2007.

  1. Ben

    Ben Guest

    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
     
    Ben, Feb 18, 2007
    #1
    1. Advertisements

  2. Ben

    Lloyd Sheen Guest

    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

    "Ben" <> wrote in message
    news:...
    > 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
    >
     
    Lloyd Sheen, Feb 18, 2007
    #2
    1. Advertisements

  3. Ben

    Phill W. Guest

    Ben wrote:

    > 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.
     
    Phill W., Feb 19, 2007
    #3
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. meh
    Replies:
    2
    Views:
    375
  2. Patrick Baker [MSFT]

    RE: How can i make HighLight a node of treeview?

    Patrick Baker [MSFT], Sep 4, 2003, in forum: Microsoft VB .NET
    Replies:
    0
    Views:
    421
    Patrick Baker [MSFT]
    Sep 4, 2003
  3. Dean Slindee

    Treeview: Node.LastNode only works at end of treeview

    Dean Slindee, Sep 29, 2003, in forum: Microsoft VB .NET
    Replies:
    1
    Views:
    227
  4. Replies:
    3
    Views:
    557
    Grant Frisken
    May 26, 2005
  5. Xenomorph

    TreeView text - possible to make it bold?

    Xenomorph, Aug 8, 2007, in forum: Microsoft VB .NET
    Replies:
    5
    Views:
    339
    Xenomorph
    Aug 10, 2007
Loading...

Share This Page