Treeview
Treeview
Treeview
Treeview
Treeview
Treeview Treeview Treeview Treeview Treeview Treeview Treeview Treeview
Treeview Treeview
Treeview
Go Back  Xtreme Visual Basic Talk > > > Treeview


Reply
 
Thread Tools Display Modes
  #1  
Old 01-05-2004, 04:11 AM
dardoleker dardoleker is offline
Newcomer
 
Join Date: Dec 2003
Posts: 8
Default Treeview


Im looking to make a treeview based file manager system that will allow files to be viewed from another machine. I have a server client system set up already, and have started working on the treeview interface before i try and update the information remotely. I searched out a tutorial on how to do it, and came across this site...

http://abstractvb.com/code.asp?F=49&P=2&A=716

I seem to be having problems getting the code to work, i believe its because of this line...

Set foNode = TreeView1.Nodes.Add(parent, tvwChild, ,_
folder.Name, "ClosedFolder")

this appears in a strange format as it is seperated and put on two lines, plus underscore is not used in vb6...

anyone tried this and have been successful in getting it to work? im also looking for links for info on how to remotely update the information... any help appreciated, cheers.
Reply With Quote
  #2  
Old 01-05-2004, 04:19 PM
Flyguy's Avatar
FlyguyTreeview Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 19,164
Default

Just make it a single line:
Code:
Set foNode = TreeView1.Nodes.Add(parent, tvwChild, ,folder.Name, "ClosedFolder")
Reply With Quote
  #3  
Old 01-06-2004, 07:50 AM
dardoleker dardoleker is offline
Newcomer
 
Join Date: Dec 2003
Posts: 8
Default ...

I put the code into one line, and that sorted the original problem, but i have another, and could use some help..

If you have read the tutorial he seems to change from using nodex to drnode to represent the drives. nodex then appears later in the code however in the remove children sub. I tried changing that but im not sure whether im interpreting what the sub is doing correctly. I also get an error in the treeview expand sub when i try to open certain drives. I havent been able to successfully expand a drive yet. heres the code im using, there is obviously a treeview control and an imagelist with 8 images, 6 for the drive types and 2 for open folder and close folder.. In a hurry to get this working, got a deadline, take a look will you?



Dim fso As New Scripting.FileSystemObject

Private Sub Form_Load()




GetDrives



End Sub

Public Sub GetDrives()


Dim dr As Scripting.Drive
Dim lsImg As String
Dim fldr As Scripting.folder
Dim drnode As Node
Dim fonode As Node


On Error Resume Next

TreeView1.Nodes.Clear
Set TreeView1.ImageList = ImageList1

For Each dr In fso.Drives
'Determine the Picture for the Drive.
Select Case dr.DriveType
Case 0: lsImg = "lala1"
Case 1: lsImg = "lala2"
Case 2: lsImg = "lala3"
Case 3: lsImg = "lala4"
Case 4: lsImg = "lala5"
Case 5: lsImg = "lala6"
End Select
Set drnode = TreeView1.Nodes.Add(, , , dr.Path, dr.DriveType)
drnode.Sorted = True

' Create a Dummy Node so we get a + beside each drive

Set fonode = TreeView1.Nodes.Add(drnode, tvwChild)
Next


End Sub




Private Sub TreeView1_Expand(ByVal Node As MSComctlLib.Node)
Dim fldr As Scripting.folder
Dim rfldr As Scripting.folder

Set rfldr = fso.GetFolder(Node.FullPath)

RemoveChildren Node

For Each fldr In rfldr.SubFolders
AddSubFolder Node, fldr
Next
End Sub

'*****************************************************
'Removes all the child nodes from the node passed
'*****************************************************
Private Sub RemoveChildren(drnode As Node)

Dim n As Node

Do While drnode.Children > 0
Set n = drnode.Child
TreeView1.Nodes.Remove n.Index
Loop
End Sub

'*****************************************************
'Adds All folders in the folder passed into it to the
'treeview control. Creating a dummy node each each that
'has folders under it.
'*****************************************************
Public Sub AddSubFolder(parent As Node, folder As Scripting.folder)
Dim fonode As Node
Dim tmpNode As Node
Dim fo As Scripting.folder

On Error Resume Next

Set fonode = TreeView1.Nodes.Add(parent, tvwChild, , folder.Name, "ClosedFolder")

fonode.ExpandedImage = "OpenFolder"
fonode.Sorted = True

'Create Dummy Node
If folder.SubFolders.Count > 0 Then
Set tmpNode = TreeView1.Nodes.Add(fonode, tvwChild)
End If
End Sub
Reply With Quote
  #4  
Old 01-07-2004, 03:31 AM
dardoleker dardoleker is offline
Newcomer
 
Join Date: Dec 2003
Posts: 8
Default ...

Set rfldr = fso.GetFolder(Node.FullPath)
whats wrong with this line?
Reply With Quote
  #5  
Old 02-23-2004, 10:48 AM
l3kris l3kris is offline
Newcomer
 
Join Date: Feb 2004
Posts: 3
Default

I know this is outdated now:

Quote:
Originally Posted by dardoleker
I seem to be having problems getting the code to work, i believe its because of this line...

Set foNode = TreeView1.Nodes.Add(parent, tvwChild, ,_
folder.Name, "ClosedFolder")




But for future reference, it must be:

Set foNode = TreeView1.Nodes.Add(parent, tvwChild, , _
folder.Name, "ClosedFolder")

- there has to be a space in front of the _ line breaker.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
TreeView Bug Mikecrosoft Interface and Graphics 6 11-28-2003 10:51 AM
Hooking or Subclassing a Treeview? LiquidPenguin General 4 04-24-2003 12:41 PM
Treeview and Imagelist, I'm completely lost Antoine General 12 03-31-2003 02:03 PM
TreeView Help Needed oceanic99 General 4 03-17-2003 10:28 AM
Treeview Help ! Megazoid General 0 11-30-2002 05:06 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Treeview
Treeview
Treeview Treeview
Treeview
Treeview
Treeview Treeview Treeview Treeview Treeview Treeview Treeview
Treeview
Treeview
 
Treeview
Treeview
 
-->