|
-
Feb 1st, 2012, 01:52 PM
#1
Thread Starter
Addicted Member
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
-
Feb 1st, 2012, 01:56 PM
#2
Re: Treeview
Code:
For Each node As TreeNode In Me.TreeView1.Nodes
node.Text = String.Format("{0}: ({1})", _
node.Text, _
node.GetNodeCount(True))
Next
-
Feb 1st, 2012, 02:01 PM
#3
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|