G
Guest
I've figured out how to enumerate through all the controls in a form
(code below) However, how would I populate the TreeView with control
names in correct hierarchial order?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim c As Control
TreeView1.BeginUpdate()
TreeView1.Nodes.Clear()
For Each c In Me.Controls
iterate(c)
Next
TreeView1.EndUpdate()
End Sub
Private Sub iterate(ByVal c As Control)
TreeView1.Nodes.Add(c.Name) ' adds all the controls w/o
hierarchy
If c.Controls.Count = 0 Then
Exit Sub
End If
Dim ctl As Control
For Each ctl In c.Controls
iterate(ctl)
Next
End Sub
End Class
(code below) However, how would I populate the TreeView with control
names in correct hierarchial order?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim c As Control
TreeView1.BeginUpdate()
TreeView1.Nodes.Clear()
For Each c In Me.Controls
iterate(c)
Next
TreeView1.EndUpdate()
End Sub
Private Sub iterate(ByVal c As Control)
TreeView1.Nodes.Add(c.Name) ' adds all the controls w/o
hierarchy
If c.Controls.Count = 0 Then
Exit Sub
End If
Dim ctl As Control
For Each ctl In c.Controls
iterate(ctl)
Next
End Sub
End Class