G
Guest
In hunting down a problem I created a simple form.
Public Class Form1
Private mOne As TreeNode
Private mTwo As TreeNode
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
LoadNodesA()
'LoadNodesB()
End Sub
Private Sub LoadNodesA()
mOne = TreeView1.Nodes.Add("One")
mTwo = TreeView1.Nodes.Add("Two")
TreeView1.SelectedNode = mTwo
End Sub
Private Sub LoadNodesB()
Dim nodes(1) As TreeNode
nodes(0) = New TreeNode("One")
mOne = nodes(0)
nodes(1) = New TreeNode("Two")
mTwo = nodes(1)
TreeView1.Nodes.AddRange(nodes)
TreeView1.SelectedNode = mOne
End Sub
End Class
The behaviour I wanted is given by LoadNodesA(). LoadLoadsB() gives a
different result. Can someone explain why the difference arises and why it is
meant to happen this way?
Thanks for any comments.
Hayrob
Public Class Form1
Private mOne As TreeNode
Private mTwo As TreeNode
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
LoadNodesA()
'LoadNodesB()
End Sub
Private Sub LoadNodesA()
mOne = TreeView1.Nodes.Add("One")
mTwo = TreeView1.Nodes.Add("Two")
TreeView1.SelectedNode = mTwo
End Sub
Private Sub LoadNodesB()
Dim nodes(1) As TreeNode
nodes(0) = New TreeNode("One")
mOne = nodes(0)
nodes(1) = New TreeNode("Two")
mTwo = nodes(1)
TreeView1.Nodes.AddRange(nodes)
TreeView1.SelectedNode = mOne
End Sub
End Class
The behaviour I wanted is given by LoadNodesA(). LoadLoadsB() gives a
different result. Can someone explain why the difference arises and why it is
meant to happen this way?
Thanks for any comments.
Hayrob