D
davidaustinarcher
Hi,
I've been having a problem clearing nodes in my treeview. Given the
following node setup:
Grandad
---Dad
------Son
There are occasions when the root tree node should be set as Dad.
However, when setting it back as Grandad I have a treeview which ends
up looking like so:
Dad
---Son
Grandad
I used a shared root node (Grandad) to store my node collection. You
can re-create this with the following code:
Public Class Form1
Dim RootNode As TreeNode
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
RootNode = New TreeNode("Grandad")
RootNode.Nodes.Add("Dad")
RootNode.Nodes(0).Nodes.Add("Son")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
TreeView1.Nodes.Clear()
TreeView1.Nodes.Add(RootNode)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button2.Click
TreeView1.Nodes.Clear()
TreeView1.Nodes.Add(RootNode.Nodes(0))
End Sub
End Class
Is this a bug or am I doing something wrong?
Best regards,
David
I've been having a problem clearing nodes in my treeview. Given the
following node setup:
Grandad
---Dad
------Son
There are occasions when the root tree node should be set as Dad.
However, when setting it back as Grandad I have a treeview which ends
up looking like so:
Dad
---Son
Grandad
I used a shared root node (Grandad) to store my node collection. You
can re-create this with the following code:
Public Class Form1
Dim RootNode As TreeNode
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
RootNode = New TreeNode("Grandad")
RootNode.Nodes.Add("Dad")
RootNode.Nodes(0).Nodes.Add("Son")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
TreeView1.Nodes.Clear()
TreeView1.Nodes.Add(RootNode)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button2.Click
TreeView1.Nodes.Clear()
TreeView1.Nodes.Add(RootNode.Nodes(0))
End Sub
End Class
Is this a bug or am I doing something wrong?
Best regards,
David