home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#2.0#0"; "MSCOMCTL.OCX"
- Begin VB.Form GlobeForm
- Appearance = 0 'Flat
- BackColor = &H80000000&
- Caption = "TreeView Demo (with non-unique items)"
- ClientHeight = 6780
- ClientLeft = 165
- ClientTop = 735
- ClientWidth = 8430
- LinkTopic = "Form1"
- ScaleHeight = 6780
- ScaleWidth = 8430
- StartUpPosition = 3 'Windows Default
- Begin VB.Frame Frame2
- Height = 6525
- Left = 5280
- TabIndex = 8
- Top = 0
- Width = 3015
- Begin VB.ListBox List1
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 3000
- Left = 150
- TabIndex = 13
- Top = 240
- Width = 2685
- End
- Begin VB.CommandButton ListCities
- Caption = "List Cities"
- BeginProperty Font
- Name = "Verdana"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 480
- Left = 480
- TabIndex = 12
- Top = 5895
- Width = 2145
- End
- Begin VB.CommandButton ListContinents
- Caption = "List Continents"
- BeginProperty Font
- Name = "Verdana"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 480
- Left = 480
- TabIndex = 11
- Top = 4440
- Width = 2145
- End
- Begin VB.CommandButton ListCountries
- Caption = "List Countries"
- BeginProperty Font
- Name = "Verdana"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 480
- Left = 495
- TabIndex = 10
- Top = 5175
- Width = 2145
- End
- Begin VB.CommandButton FindCity
- Caption = "Find KEY"
- BeginProperty Font
- Name = "Verdana"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 480
- Left = 480
- TabIndex = 9
- Top = 3705
- Width = 2145
- End
- End
- Begin VB.CommandButton ExpandNodeBttn
- Caption = "Expand Current Node"
- BeginProperty Font
- Name = "Verdana"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 465
- Left = 2625
- TabIndex = 7
- Top = 3435
- Width = 2400
- End
- Begin VB.CommandButton DeleteNodeBttn
- Caption = "Delete Current Node"
- BeginProperty Font
- Name = "Verdana"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 465
- Left = 180
- TabIndex = 6
- Top = 3435
- Width = 2400
- End
- Begin VB.CommandButton AddEntry
- Caption = "Add this Node"
- BeginProperty Font
- Name = "Verdana"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 465
- Left = 3210
- TabIndex = 4
- Top = 5835
- Width = 1575
- End
- Begin VB.TextBox Text3
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 330
- Left = 2535
- TabIndex = 3
- Top = 5310
- Width = 2220
- End
- Begin VB.TextBox Text2
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 330
- Left = 1590
- TabIndex = 2
- Top = 4890
- Width = 2220
- End
- Begin VB.TextBox Text1
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 330
- Left = 345
- TabIndex = 1
- Top = 4425
- Width = 2220
- End
- Begin ComctlLib.TreeView TreeView1
- Height = 3105
- Left = 165
- TabIndex = 0
- Top = 165
- Width = 4890
- _ExtentX = 8625
- _ExtentY = 5477
- _Version = 393217
- HideSelection = 0 'False
- LabelEdit = 1
- Sorted = -1 'True
- Style = 6
- HotTracking = -1 'True
- Appearance = 1
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- _Nodes = "TView.frx":0000
- End
- Begin VB.Frame Frame1
- Height = 2430
- Left = 150
- TabIndex = 5
- Top = 4065
- Width = 4905
- Begin VB.Line Line1
- X1 = 375
- X2 = 375
- Y1 = 690
- Y2 = 1395
- End
- Begin VB.Line Line2
- X1 = 1455
- X2 = 375
- Y1 = 975
- Y2 = 975
- End
- Begin VB.Line Line4
- X1 = 2400
- X2 = 360
- Y1 = 1395
- Y2 = 1395
- End
- End
- Begin ComctlLib.ImageList ImageList1
- Left = 15
- Top = 3675
- _ExtentX = 1005
- _ExtentY = 1005
- BackColor = -2147483643
- MaskColor = 12632256
- _Version = 393216
- End
- Begin VB.Menu FileMenu
- Caption = "File"
- Begin VB.Menu FileLoad
- Caption = "Load Control"
- End
- Begin VB.Menu FileSave
- Caption = "Save Control"
- End
- Begin VB.Menu sep
- Caption = "-"
- End
- Begin VB.Menu FileExit
- Caption = "Exit"
- End
- End
- Attribute VB_Name = "GlobeForm"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- ' ******************************
- ' ******************************
- ' ** MASTERING VB6 **
- ' ** by Evangelos Petroutos **
- ' ** SYBEX, 1998 **
- ' ******************************
- ' ******************************
- Option Explicit
- Private Sub FileLoad_Click()
- Dim FNum As Integer
- Dim Nd As Node
- Dim level1 As String, level2 As String
- Dim key As String, thisItem As String
- Dim nodeText As String
- TreeView1.Nodes.Clear
- ' set up the ListImage object
- Dim Images As ListImage
- Set Images = ImageList1.ListImages.Add(, , LoadPicture(App.Path & "\cont.bmp"))
- Set Images = ImageList1.ListImages.Add(, , LoadPicture(App.Path & "\country.bmp"))
- Set Images = ImageList1.ListImages.Add(, , LoadPicture(App.Path & "\city.bmp"))
- TreeView1.ImageList = ImageList1
- FNum = FreeFile()
- Set Nd = TreeView1.Nodes.Add(, , "GLOBE", "Globe", 1)
- Nd.Tag = "GLOBE"
- Nd.Sorted = True
- Open App.Path & "\MGlobe.txt" For Input As #FNum
- While Not EOF(FNum)
- Input #FNum, nodeText
- thisItem = UCase(Trim(nodeText))
- If Left(nodeText, 3) = " " Then
- key = level2 & "-" & thisItem
- Set Nd = TreeView1.Nodes.Add(level2, tvwChild, key, Trim(nodeText), 3)
- Nd.Tag = "Cities"
- ElseIf Left(nodeText, 2) = " " Then
- level2 = level1 & "-" & thisItem
- key = level2
- Set Nd = TreeView1.Nodes.Add(level1, tvwChild, key, Trim(nodeText), 2)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- ElseIf Left(nodeText, 1) = " " Then
- level1 = thisItem
- key = level1
- Set Nd = TreeView1.Nodes.Add("GLOBE", tvwChild, key, Trim(nodeText), 1)
- Nd.Tag = "Continents"
- Nd.Sorted = True
- End If
- Wend
- Close #FNum
- End Sub
- Private Sub FileSave_Click()
- Dim Nd As Node, countryNd As Node, continentNd As Node, cityNd As Node
- Dim continent As Integer, continents As Integer
- Dim country As Integer, countries As Integer
- Dim city As Integer, cities As Integer
- Dim FNum As Integer
- FNum = FreeFile()
- Open App.Path & "\MGlobe.txt" For Output As #FNum
- Set Nd = TreeView1.Nodes.Item("GLOBE")
- Debug.Print Nd.Text
- Write #FNum, Nd.Text
- continents = Nd.Children
- Set continentNd = Nd.Child
- For continent = 1 To continents
- Debug.Print continentNd.Text
- Write #FNum, " " & continentNd.Text
- countries = continentNd.Children
- Set countryNd = continentNd.Child
- For country = 1 To countries
- Debug.Print " " & countryNd.Text
- Write #FNum, " " & countryNd.Text
- cities = countryNd.Children
- Set cityNd = countryNd.Child
- For city = 1 To cities
- Debug.Print " " & cityNd.Text
- Write #FNum, " " & cityNd.Text
- Set cityNd = cityNd.Next
- Next
- Set countryNd = countryNd.Next
- Next
- Set continentNd = continentNd.Next
- Next
- Close #FNum
- End Sub
- Private Sub AddEntry_Click()
- Dim newNode As Node
- Dim NodeContinent As Node, NodeCountry As Node, NodeCity As Node
- On Error Resume Next
- If Trim(Text1.Text) = "" Then
- MsgBox "Please supply a valid key in the form Continent-Country-City"
- Exit Sub
- End If
- Set newNode = TreeView1.Nodes.Item(UCase$(Text1.Text))
- If Error Then
- Set newNode = TreeView1.Nodes.Add("GLOBE", tvwChild, UCase$(Text1.Text), Text1.Text, 2)
- newNode.Tag = "Continents"
- End If
- If Trim(Text2.Text) = "" Then Exit Sub
- Set newNode = TreeView1.Nodes.Item(UCase$(Text1.Text & "-" & Text2.Text))
- If Error Then
- Set newNode = TreeView1.Nodes.Add(UCase$(Text1.Text), tvwChild, UCase$(Text1.Text & "-" & Text2.Text), Text2.Text, 3)
- newNode.Tag = "Countries"
- End If
- If Trim(Text3.Text) = "" Then Exit Sub
- Set newNode = TreeView1.Nodes.Item(UCase$(Text1.Text & "-" & Text2.Text & "-" & Text3.Text))
- If Error Then
- Set newNode = TreeView1.Nodes.Add(UCase$(Text1.Text & "-" & Text2.Text), tvwChild, UCase$(Text1.Text & "-" & Text2.Text & "-" & Text3.Text), Text3.Text)
- newNode.Tag = "Cities"
- End If
- TreeView1.SelectedItem = newNode
- End Sub
- Private Sub DeleteNodeBttn_Click()
- TreeView1.Nodes.Remove (TreeView1.SelectedItem.Index)
- Text1.Text = ""
- Text2.Text = ""
- Text3.Text = ""
- End Sub
- Private Sub ExpandNodeBttn_Click()
- TreeView1.SelectedItem.Expanded = True
- End Sub
- Private Sub FindCity_Click()
- Dim Nd As Node, ParentNd As Node
- Dim NodeName As String, NodeKey As String
- Text1.Text = ""
- Text2.Text = ""
- Text3.Text = ""
- On Error GoTo NoCity
- NodeName = InputBox("Enter name of node")
- NodeKey = UCase$(Trim(NodeName))
- Set Nd = TreeView1.Nodes.Item(NodeKey)
- TreeView1.SelectedItem = Nd
- Text1.Text = Nd.Text
- Set ParentNd = Nd.Parent
- If Not ParentNd Is Nothing Then
- If ParentNd.key = "GLOBE" Then
- Exit Sub
- Else
- NodeKey = UCase$(ParentNd.key)
- TreeView1.Nodes(NodeKey).Expanded = True
- Text2.Text = Text1.Text
- Text1.Text = ParentNd.Text
- End If
- End If
- Set ParentNd = ParentNd.Parent
- If Not ParentNd Is Nothing Then
- If ParentNd.key = "GLOBE" Then
- Exit Sub
- Else
- NodeKey = UCase$(ParentNd.key)
- TreeView1.Nodes(NodeKey).Expanded = True
- Text3.Text = Text2.Text
- Text2.Text = Text1.Text
- Text1.Text = ParentNd.Text
- End If
- End If
- Set ParentNd = ParentNd.Parent
- If Not ParentNd Is Nothing Then
- If Not ParentNd.key = "GLOBE" Then
- NodeKey = UCase$(ParentNd.key)
- TreeView1.Nodes(NodeKey).Expanded = True
- End If
- End If
- Exit Sub
- NoCity:
- If Err.Number = 35601 Then
- MsgBox "The city you requested does not exist"
- Else
- MsgBox Err.Description
- End If
- End Sub
- Private Sub Form_Load()
- Dim Images As ListImage
- Dim Nd As Node
- ' set up the ListImage object
- Set Images = ImageList1.ListImages.Add(, , LoadPicture(App.Path & "\cont.bmp"))
- Set Images = ImageList1.ListImages.Add(, , LoadPicture(App.Path & "\country.bmp"))
- Set Images = ImageList1.ListImages.Add(, , LoadPicture(App.Path & "\city.bmp"))
- TreeView1.ImageList = ImageList1
- ' now set up Treeview control
- Set Nd = TreeView1.Nodes.Add(, , "GLOBE", "Globe", 1)
- Nd.Tag = "GLOBE"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("GLOBE", tvwChild, "EUROPE", "EUROPE", 2)
- Nd.Tag = "Continents"
- Nd.Sorted = True ' this statement sorts all countries under EUROPE
- Set Nd = TreeView1.Nodes.Add("GLOBE", tvwChild, "ASIA", "ASIA", 2)
- Nd.Tag = "Continents"
- Nd.Sorted = True ' this statement sorts all countries under ASIA
- Set Nd = TreeView1.Nodes.Add("GLOBE", tvwChild, "AFRICA", "AFRICA", 2)
- Nd.Tag = "Continents"
- Nd.Sorted = True ' ' this statement sorts all countries under AFRICA
- Set Nd = TreeView1.Nodes.Add("GLOBE", tvwChild, "AMERICA", "AMERICA", 2)
- Nd.Tag = "Continents"
- Nd.Sorted = True ' this statement sorts all countries under AMERICA
- Set Nd = TreeView1.Nodes.Add("GLOBE", tvwChild, "OCEANIA", "OCEANIA", 2)
- Nd.Tag = "Continents"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("EUROPE", tvwChild, "EUROPE-GERMANY", "Germany", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True ' this statement sorts all german cities
- Set Nd = TreeView1.Nodes.Add("EUROPE-GERMANY", tvwChild, "EUROPE-GERMANY-BERLIN", "Berlin")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("EUROPE-GERMANY", tvwChild, "EUROPE-GERMANY-MUNICH", "Munich")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("EUROPE-GERMANY", tvwChild, "EUROPE-GERMANY-BAYREUTH", "Bayreuth")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("EUROPE-GERMANY", tvwChild, "EUROPE-GERMANY-FRANFURT", "Frankfurt")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("EUROPE", tvwChild, "EUROPE-FRANCE", "France", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True ' this statement sorts all french cities
- Set Nd = TreeView1.Nodes.Add("EUROPE-FRANCE", tvwChild, "EUROPE-FRANCE-PARIS", "Paris")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("EUROPE-FRANCE", tvwChild, "EUROPE-FRANCE-NICE", "Nice")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("EUROPE-FRANCE", tvwChild, "EUROPE-FRANCE-LYON", "Lyon")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("EUROPE", tvwChild, "EUROPE-ITALY", "Italy", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True ' this statement sorts all italian cities
- Set Nd = TreeView1.Nodes.Add("EUROPE-ITALY", tvwChild, "EUROPE-ITALY-ROME", "Rome")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("EUROPE-ITALY", tvwChild, "EUROPE-ITALY-VENICE", "Venice")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("EUROPE-ITALY", tvwChild, "EUROPE-ITALY-NAPOLI", "Napoli")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("ASIA", tvwChild, "ASIA-CHINA", "China", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("ASIA-CHINA", tvwChild, "ASIA-CHINA-BEJING", "Bejing")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("ASIA", tvwChild, "ASIA-JAPAN", "Japan", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("ASIA-JAPAN", tvwChild, "ASIA-JAPAN-TOKYO", "Tokyo")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("ASIA-JAPAN", tvwChild, "ASIA-JAPAN-OSAKA", "Osaka")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AFRICA", tvwChild, "AFRICA-EGYPT", "Egypt", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("AFRICA-EGYPT", tvwChild, "AFRICA-EGYPT-CAIRO", "Cairo")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AFRICA-EGYPT", tvwChild, "AFRICA-EGYPT-ALEXANDRIA", "Alexandria")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AFRICA", tvwChild, "AFRICA-LIBYA", "Libya", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("AFRICA-LIBYA", tvwChild, "AFRICA-LIBYA-TRIPOLI", "Tripoli")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AFRICA", tvwChild, "AFRICA-SOUTH AFRICA", "South Africa", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("AFRICA-SOUTH AFRICA", tvwChild, "AFRICA-SOUTH AFRICA-JOHANNESBURG", "Johannesburg")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AFRICA-SOUTH AFRICA", tvwChild, "AFRICA-SOUTH AFRICA-PRETORIA", "Pretoria")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AFRICA", tvwChild, "AFRICA-ZIMBABWE", "Zimbabwe", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("AFRICA-ZIMBABWE", tvwChild, "AFRICA-ZIMBABWE-HARARE", "Harare")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("OCEANIA", tvwChild, "OCEANIA-AUSTRALIA", "Australia", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("OCEANIA-AUSTRALIA", tvwChild, "OCEANIA-AUSTRALIA-SINDEY", "Sidney")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("OCEANIA-AUSTRALIA", tvwChild, "OCEANIA-AUSTRALIA-MELBOURNE", "Melbourne")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("OCEANIA-AUSTRALIA", tvwChild, "OCEANIA-AUSTRALIA-ADELAIADE", "Adelaida")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("OCEANIA-AUSTRALIA", tvwChild, "OCEANIA-AUSTRALIA-BRISBANE", "Brisbane")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("OCEANIA-AUSTRALIA", tvwChild, "OCEANIA-AUSTRALIA-CANBERRA", "Canberra")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("OCEANIA", tvwChild, "OCEANIA-NEW ZEALAND", "New Zealand", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("OCEANIA-NEW ZEALAND", tvwChild, "OCEANIA-NEW ZEALAND-WANAKA", "Wanaka")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AMERICA", tvwChild, "AMERICA-USA", "USA", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("AMERICA-USA", tvwChild, "AMERICA-USA-NEW YORK", "New York")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AMERICA-USA", tvwChild, "AMERICA-USA-LAS VEGAS", "Las Vegas")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AMERICA-USA", tvwChild, "AMERICA-USA-CHICAGO", "Chicago")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AMERICA-USA", tvwChild, "AMERICA-USA-WASHINGTON", "Washington")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AMERICA-USA", tvwChild, "AMERICA-USA-DURHAM", "Durham")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AMERICA-USA", tvwChild, "AMERICA-USA-VENICE", "Venice")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AMERICA-USA", tvwChild, "AMERICA-USA-Alexandria", "Alexandria")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AMERICA-USA", tvwChild, "AMERICA-USA-SAN FRANCISCO", "San Francisco")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AMERICA", tvwChild, "AMERICA-CANADA", "Canada", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("AMERICA-CANADA", tvwChild, "AMERICA-CANADA-TORONTO", "Toronto")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AMERICA-CANADA", tvwChild, "AMERICA-CANADA-VANCOUVER", "Vancouver")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AMERICA-CANADA", tvwChild, "AMERICA-CANADA-MONTREAL", "Montreal")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AMERICA-CANADA", tvwChild, "AMERICA-CANADA-HALIFAX", "Halifax")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AMERICA-CANADA", tvwChild, "AMERICA-CANADA-CALGARY", "Calgary")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AMERICA", tvwChild, "AMERICA-MEXICO", "Mexico", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("AMERICA-MEXICO", tvwChild, "AMERICA-MEXICO-MEXICO CITY", "Mexico City")
- Nd.Tag = "Cities"
- Set Nd = TreeView1.Nodes.Add("AMERICA", tvwChild, "AMERICA-ARGENTINA", "Argentina", 3)
- Nd.Tag = "Countries"
- Nd.Sorted = True
- Set Nd = TreeView1.Nodes.Add("AMERICA-ARGENTINA", tvwChild, "AMERICA-ARGENTINA-BUENOS AIRES", "Buenos Aires")
- Nd.Tag = "Cities"
- End Sub
- Private Sub ListCities_Click()
- Dim Nd As Node, countryNd As Node, continentNd As Node, cityNd As Node
- Dim continent As Integer, continents As Integer
- Dim country As Integer, countries As Integer
- Dim city As Integer, cities As Integer
- List1.Clear
- Set Nd = TreeView1.Nodes.Item("GLOBE")
- continents = Nd.Children
- Set continentNd = Nd.Child
- For continent = 1 To continents
- countries = continentNd.Children
- Set countryNd = continentNd.Child
- For country = 1 To countries
- cities = countryNd.Children
- Set cityNd = countryNd.Child
- For city = 1 To cities
- List1.AddItem cityNd.Text
- Set cityNd = cityNd.Next
- Next
- Set countryNd = countryNd.Next
- Next
- Set continentNd = continentNd.Next
- Next
- End Sub
- Private Sub ListContinents_Click()
- Dim Nd As Node, childNd As Node
- Dim continent As Integer, continents As Integer
- List1.Clear
- Set Nd = TreeView1.Nodes.Item("GLOBE")
- continents = Nd.Children
- Set childNd = Nd.Child
- For continent = 1 To continents
- List1.AddItem childNd.Text
- Set childNd = childNd.Next
- Next
- End Sub
- Private Sub ListCountries_Click()
- Dim Nd As Node, countryNd As Node, continentNd As Node
- Dim continent As Integer, continents As Integer
- Dim country As Integer, countries As Integer
- List1.Clear
- Set Nd = TreeView1.Nodes.Item("GLOBE")
- continents = Nd.Children
- Set continentNd = Nd.Child
- For continent = 1 To continents
- countries = continentNd.Children
- Set countryNd = continentNd.Child
- For country = 1 To countries
- List1.AddItem countryNd.Text
- Set countryNd = countryNd.Next
- Next
- Set continentNd = continentNd.Next
- Next
- End Sub
- Private Sub TreeView1_NodeClick(ByVal Node As ComctlLib.Node)
- Dim Nd As Node, childNd As Node
- Dim i As Integer
- Text1.Text = ""
- Text2.Text = ""
- Text3.Text = ""
- Set Nd = Node
- Me.Caption = Nd.FullPath
- Nd.Expanded = Not Nd.Expanded
- ' Uncomment the following lines to display the
- ' current node's children in the ListBox control
- ' If Nd.Children > 0 Then
- ' List1.Clear
- ' Set childNd = Nd.Child
- ' For i = 0 To Nd.Children - 1
- ' List1.AddItem childNd.Text
- ' Set childNd = childNd.Next
- ' Next
- ' End If
- Set Nd = Node
- If Nd.Tag = "GLOBE" Then Exit Sub
- If Nd.Tag = "Cities" Then
- Text3.Text = Nd.Text
- Set Nd = Nd.Parent
- Text2.Text = Nd.Text
- Set Nd = Nd.Parent
- Text1.Text = Nd.Text
- ElseIf Nd.Tag = "Countries" Then
- Text3.Text = ""
- Text2.Text = Nd.Text
- Set Nd = Nd.Parent
- Text1.Text = Nd.Text
- Else
- Text1.Text = Nd.Text
- Text2.Text = ""
- Text3.Text = ""
- End If
- End Sub
-