Click here to Skip to main content
15,886,362 members
Articles / Programming Languages / Visual Basic

Fill a Tree

Rate me:
Please Sign up or sign in to vote.
1.62/5 (11 votes)
2 Sep 2004CPOL1 min read 40.4K   1.1K   12  
I sometime need to show things in tree manner. This is not big problem unless you try to fill it from database. Since in .NET there is no key and child adding like in VB6 things have to be done recursively.
Public Class frmMain
	Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

	Public Sub New()
		MyBase.New()

		'This call is required by the Windows Form Designer.
		InitializeComponent()

		'Add any initialization after the InitializeComponent() call

	End Sub

	'Form overrides dispose to clean up the component list.
	Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
		If disposing Then
			If Not (components Is Nothing) Then
				components.Dispose()
			End If
		End If
		MyBase.Dispose(disposing)
	End Sub

	'Required by the Windows Form Designer
	Private components As System.ComponentModel.IContainer

	'NOTE: The following procedure is required by the Windows Form Designer
	'It can be modified using the Windows Form Designer.  
	'Do not modify it using the code editor.
	Friend WithEvents trvDB As System.Windows.Forms.TreeView
	<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
		Me.trvDB = New System.Windows.Forms.TreeView
		Me.SuspendLayout()
		'
		'trvDB
		'
		Me.trvDB.Dock = System.Windows.Forms.DockStyle.Fill
		Me.trvDB.ImageIndex = -1
		Me.trvDB.Location = New System.Drawing.Point(0, 0)
		Me.trvDB.Name = "trvDB"
		Me.trvDB.SelectedImageIndex = -1
		Me.trvDB.Size = New System.Drawing.Size(232, 446)
		Me.trvDB.TabIndex = 0
		'
		'frmMain
		'
		Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
		Me.ClientSize = New System.Drawing.Size(232, 446)
		Me.Controls.Add(Me.trvDB)
		Me.Font = New System.Drawing.Font("Tahoma", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(238, Byte))
		Me.MinimumSize = New System.Drawing.Size(160, 100)
		Me.Name = "frmMain"
		Me.Text = "dbTree"
		Me.ResumeLayout(False)

	End Sub

#End Region

	Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		FillTree(trvDB)
	End Sub


End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Croatia Croatia
VB programmer with MCSD status. Loves chevapi...

Medo's Home Page

Comments and Discussions