Showing files in listview from child nodes and parent nodes in treeview vb.net visual studio 2010

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<span style="font-family:Verdana,sans-serif; font-size:9pt Hello<o:p></o:p>
<span style="font-family:Verdana,sans-serif; font-size:9pt Im trying<br/>
to create a windows explorer so i can browse around and look at files that show up, Im currently using an TreeView and a ListView which are in a SplitContainer.<o:p></o:p>
<span style="font-family:Verdana,sans-serif; font-size:9pt Im using aTreeView as the directory for the drive c:, Im also using Listview so i can show the files which are in the child nodes or pare<span style="font-family:Verdana,sans-serif; font-size:9pt nt
nodes. But im having problems with trying to get access to files that are hidden in the parent nodes and child nodes. i just wonder if anyway could share some ideas. Ive keep the code simple as possible as im only a student.

this is the current code i have.
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Consolas; font-size:9.5pt Imports<span style="font-family:Consolas; font-size:9.5pt System.IO
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Consolas; font-size:9.5pt Imports<span style="font-family:Consolas; font-size:9.5pt Microsoft.VisualBasic.FileIO
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Consolas; font-size:9.5pt Public<span style="font-family:Consolas; font-size:9.5pt
<span style="color:blue Class <span style="color:#2b91af Form1
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue Private <span style="color:blue Sub Form1_Load(sender
<span style="color:blue As System.<span style="color:#2b91af Object, e
<span style="color:blue As System.<span style="color:#2b91af EventArgs)
<span style="color:blue Handles <span style="color:blue MyBase.Load
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue Dim rootnode <span style="color:blue As
<span style="color:blue New <span style="color:#2b91af TreeNode(<span style="color:#a31515 "C:")
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
TreeView1.Nodes.Add(rootnode)
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
FillChildNodes(rootnode)
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
TreeView1.Nodes(0).Expand()
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
ListView1.View = <span style="color:#2b91af View.Details
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
ListView1.Sorting = <span style="color:blue True
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
ListView1.Columns.Add(<span style="color:#a31515 "File Name", 150,
<span style="color:#2b91af HorizontalAlignment.Left)
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue End <span style="color:blue Sub
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span style="color:blue
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue Private <span style="color:blue Sub ExitToolStripMenuItem_Click(sender
<span style="color:blue As System.<span style="color:#2b91af Object, e
<span style="color:blue As System.<span style="color:#2b91af EventArgs)
<span style="color:blue Handles ExitToolStripMenuItem.Click
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue Try
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:#2b91af Application.Exit()
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue Catch ex <span style="color:blue As
<span style="color:#2b91af Exception
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue End <span style="color:blue Try
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue End <span style="color:blue Sub
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span style="color:blue
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue Private <span style="color:blue Sub FillChildNodes(Node
<span style="color:blue As <span style="color:#2b91af TreeNode)
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue Try
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue Dim dirs <span style="color:blue As
<span style="color:blue New <span style="color:#2b91af DirectoryInfo(Node.FullPath)
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue For <span style="color:blue Each Dir
<span style="color:blue As <span style="color:#2b91af DirectoryInfo
<span style="color:blue In dirs.GetDirectories()
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue Dim newmode <span style="color:blue As
<span style="color:blue New <span style="color:#2b91af TreeNode(Dir.Name)
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
Node.Nodes.Add(newmode)
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
newmode.Nodes.Add(<span style="color:#a31515 "*")
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue Next
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue Catch ex <span style="color:blue As
<span style="color:#2b91af Exception
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue End <span style="color:blue Try
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue End <span style="color:blue Sub
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span style="color:blue
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue Private <span style="color:blue Sub TreeView1_BeforeExpand(sender
<span style="color:blue As <span style="color:blue Object, e <span style="color:blue
As System.Windows.Forms.<span style="color:#2b91af TreeViewCancelEventArgs)
<span style="color:blue Handles TreeView1.BeforeExpand
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue Try
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue If e.Node.Nodes(0).Text = (<span style="color:#a31515 "*")
<span style="color:blue Then
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
e.Node.Nodes.Clear()
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
FillChildNodes(e.Node)
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue End <span style="color:blue If
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue Catch ex <span style="color:blue As
<span style="color:#2b91af Exception
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue End <span style="color:blue Try
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue End <span style="color:blue Sub
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span style="color:blue
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue Private <span style="color:blue Sub TreeView1_AfterSelect(sender
<span style="color:blue As System.<span style="color:#2b91af Object, e
<span style="color:blue As System.Windows.Forms.<span style="color:#2b91af TreeViewEventArgs)
<span style="color:blue Handles TreeView1.AfterSelect
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span> ToolStripLabel1.Text = e.Node.FullPath
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue End <span style="color:blue Sub

Thanks

<span style="font-family:Verdana,sans-serif; font-size:9pt <o:p></o:p>
<br/>

View the full article
 
Back
Top