Results 1 to 3 of 3

Thread: Treeview

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2012
    Posts
    142

    Treeview

    Hi!
    I am trying to get a root node to have the count of the childrens in its text. i.e. I have a root called Employees, I want it to say Employees (29)
    Help is appreciated. Heres what I tried


    Code:
    Private Sub TreeView1_DrawNode(ByVal sender As Object, ByVal e As DrawTreeNodeEventArgs) Handles Inv.DrawNode
            If e.Node.Parent Is Nothing OrElse e.Node.Parent.Parent Is Nothing Then
                Inv.Nodes(0).Nodes(0).Text = Inv.Nodes(0).Nodes(0).Text + Inv.Nodes(0).Nodes(0).Nodes.Count
            End If
    
            e.DrawDefault = True
        End Sub

  2. #2
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: Treeview

    Code:
    For Each node As TreeNode In Me.TreeView1.Nodes
        node.Text = String.Format("{0}: ({1})", _
                                  node.Text, _
                                  node.GetNodeCount(True))
    Next

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2012
    Posts
    142

    Re: Treeview

    I changed it to this:
    Code:
    Private Sub TreeView1_DrawNode(ByVal sender As Object, ByVal e As DrawTreeNodeEventArgs) Handles Inv.DrawNode
            If e.Node.Parent Is Nothing OrElse e.Node.Parent.Parent Is Nothing Then
                Inv.Nodes(0).Nodes(0).Text = Inv.Nodes(0).Nodes(0).Text + Inv.Nodes(0).Nodes(0).Nodes.Count
            End If
    
            e.DrawDefault = True
        End Sub
    and made the treeviews drawmode ownerdrawtext, but now it makes it Employees 1 1 1 1 1 1 1 1 1 1 1 1.(with 1 employee)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width