Returns a reference to the last sibling of a Node object in a TreeView control.
Syntax
object.LastSibling
The object placeholder represents an object expression that evaluates to an object in the Applies To list.
Remarks
The last sibling is the Node that appears in the last position in one level of a hierarchy of nodes. Which Node actually appears in the last position depends on whether or not the Node objects at that level are sorted, which is determined by the Sorted property. To sort the Node objects at one level, set the Sorted property of the Parent node to True. The following code demonstrates this:
Private Sub TreeView1_NodeClick(ByVal Node As Node)
Node.Parent.Sorted = True
End Sub
The Child, FirstSibling, LastSibling, Previous, Parent, Next, and Root properties all return a reference to another Node object. Therefore, you can simultaneously reference and perform operations on a Node, as follows:
With TreeView1.Nodes(x).LastSibling
.Text = "New text"
.Key = "New key"
.SelectedImage = 3
End With
You can also set an object variable to the referenced Node, as follows:
Dim NodLastSib As Node
' Get a reference to the last sibling of Node x.
Set NodLastSib = TreeView1.Nodes(x).LastSibling
' Use this reference to perform operations on the sibling Node.
With nodLastSib
.Text = "New text" ' Change the text.
.Key = "New key" ' Change key.
.SelectedImage = 3 ' Change SelectedImage.
End With