|
-
Feb 3rd, 2003, 07:38 PM
#1
Thread Starter
Member
How to automaticly add nodes to the treeview?
Hi, I was wondering, how do you automaticly add items to the treeview when you start the program?
When it starts, I want it to look for a certain type of file in a certain folder that the user selects, and for each file add a new node to the Treeview.
Please help....
Josh
Smartbar XP is WAY better then Dashboard. http://www.smartbarxp.com
-
Feb 3rd, 2003, 10:46 PM
#2
Thread Starter
Member
anybody? please help, its important!
Josh
Smartbar XP is WAY better then Dashboard. http://www.smartbarxp.com
-
Feb 4th, 2003, 04:55 PM
#3
Hyperactive Member
Something like this?
VB Code:
Private Sub RefreshList()
Dim Imageindex As Short = 0
Try
Dim topics() As String = Directory.GetDirectories("[i]<your start directory>[/i]")
Dim str As String
For Each str In topics
'Dim Imageindex As Short
Dim dir As New DirectoryInfo(str)
Dim fi() As FileInfo = dir.GetFiles("*.rtf")
Dim node As New TreeNode(str.Substring(str.IndexOf("\") + 1), Imageindex, Imageindex)
TreeView1.Nodes.Add(node)
Dim f As FileInfo
For Each f In fi
node.Nodes.Add(f.Name.Remove(f.Name.IndexOf("."), 4))
Next
Imageindex += 1
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
just call RefreshList() to create the Treeview.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|