The sample file that I am using is your treeViewForm.vb, from your 1.4.0.7 distribution. It has a modification date of 1/16/2006. It includes the following methods.
Private Sub hideSelectedBtn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles hideSelectedBtn.Click
If Not treeviewGrid.Selected Is Nothing Then
treeviewGrid.Selected.Hidden = True
Else
MessageBox.Show(\"Nothing selected!\")
End If
End Sub
Private Sub showHiddenNodesBtn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles showHiddenNodesBtn.Click
For Each n As Node In treeviewGrid.Rows.Items
n.Hidden = False
If n.HasChildren Then
ShowNodes(n.Items)
End If
Next n
End Sub
Private Sub ShowNodes(ByVal nodes As NodeCollection)
For Each n As Node In nodes
n.Hidden = False
If n.HasChildren Then
ShowNodes(n.Items)
End If
Next n
End Sub
These methods do not include any BeginInit()/EndInit() pairs.
I would not expect the pair to be required, given the documentation (below) and the fact that this code is updating the state of the nodes, not initializing the component.
The various .NET design environments use this method to start the initialization of a component that is used on a form or used by another component. The EndInit method ends the initialization. Using the BeginInit and EndInit methods prevents the control from being used before it is fully initialized.
In my own code, I included a BeginUpdate()/EndUpdate() pair, assuming that they would improve performance. I have not had to use BeginInit()/EndInit() in any of the other modifications that I have made to the nodes and everything else works fine.
Your treeViewForm.vb works properly as well, as long as there is at least one node in the tree that is not hidden. However, if you hide all of the nodes (e.g., per the instructions in my initial post) then they are not revealed when you set the hidden property to false.