Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class TreeViewCreationInCode
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
Public Class Form1
Inherits System.Windows.Forms.Form
Dim TreeView1 As TreeView
Public Sub New()
MyBase.New()
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 293)
TreeView1 = New TreeView
TreeView1.Location = New Point(75, 100)
TreeView1.Size = New Size(150, 150)
Controls.Add(TreeView1)
TreeView1.Nodes.Clear()
Dim RootNode = New TreeNode("Root")
TreeView1.Nodes.Add(RootNode)
TreeView1.Nodes(0).Nodes.Add(New TreeNode("Node 1"))
For intLoopIndex As Integer = 2 To 3
TreeView1.Nodes(0).Nodes(0).Nodes.Add(New _
TreeNode("Node" & Str(intLoopIndex)))
Next intLoopIndex
TreeView1.Nodes(0).Nodes.Add(New TreeNode("Node 4"))
For intLoopIndex As Integer = 5 To 6
TreeView1.Nodes(0).Nodes(1).Nodes.Add(New _
TreeNode("Node" & Str(intLoopIndex)))
Next intLoopIndex
End Sub
End Class
|