For i = 0 To TreeViewAdv1.Controls.Count - 1
TreeViewAdv1.Controls(i).Location = New Point(200, 0)
Next
'To set the location of the Nodes.
Me.treeViewAdv1.Indent += 10
'To Set the location for the custom control.
For i As Integer = 0 To Me.treeViewAdv1.Nodes.Count - 1
Me.treeViewAdv1.Nodes(i).CustomControlLocation = New Point(Me.treeViewAdv1.Nodes(i).CustomControlLocation.X + 10, Me.treeViewAdv1.Nodes(i).CustomControlLocation.Y)
Next i
|
Private Sub buttonAdv2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonAdv2.Click
'To Set the location for the custom control.
Dim node As TreeNodeAdv = Nothing
Dim longest As String = Me.treeViewAdv1.Nodes(0).Nodes(0).Text
'To find the largest test from the collection of child node.
For Each tree As TreeNodeAdv In Me.treeViewAdv1.Nodes(0).Nodes
If tree.Text.Length > longest.Length Then
node = tree
longest = node.Text
End If
Next
'To set the customcontrol location.
For Each custombound As TreeNodeAdv In Me.treeViewAdv1.Nodes(0).Nodes
custombound.CustomControlLocation = New Point((node.TextBounds.X + node.TextBounds.Width - custombound.TextBounds.Width), custombound.CustomControlLocation.Y)
Next
End Sub
|