Tree View and Folders directories
-
Hi All I want ask you how can i use tree wiew in VB.NET to brows for folders in specific drive(c:\,d:\,.....) i want to view all files and i want to open them when them clicked (i want VB.NET code to implemnt this problem in other words my problem seem like Tree of folders in windows when we select folder all it's content are open beside it and we can select any file by click on it)
-
Hi All I want ask you how can i use tree wiew in VB.NET to brows for folders in specific drive(c:\,d:\,.....) i want to view all files and i want to open them when them clicked (i want VB.NET code to implemnt this problem in other words my problem seem like Tree of folders in windows when we select folder all it's content are open beside it and we can select any file by click on it)
i am not sure what you are looking for but you can use the OpenFileDialog found in VB.NET if this is not good for you and you want to implement something like windows explorer you have to write your own code to browse files and folders and add them to the tree view. hope this helps you
-
i am not sure what you are looking for but you can use the OpenFileDialog found in VB.NET if this is not good for you and you want to implement something like windows explorer you have to write your own code to browse files and folders and add them to the tree view. hope this helps you
Thank You Sir I need to know how to implement something like windows explorer (My problems looks like when we open My Computer and then click on the icon Folders we see tree on the left of the screen and on the right we see all files and folder in specific directory I need to implement this) I look forward to hear from you soon
-
Thank You Sir I need to know how to implement something like windows explorer (My problems looks like when we open My Computer and then click on the icon Folders we see tree on the left of the screen and on the right we see all files and folder in specific directory I need to implement this) I look forward to hear from you soon
Dim Files() As String = System.IO.Directory.GetFiles("c:\") Dim Folders() As String = System.IO.Directory.GetDirectories("C:\") For Each F As String In Folders If (System.IO.File.GetAttributes(F) And IO.FileAttributes.Hidden) <> IO.FileAttributes.Hidden Then Me.TreeView1.Nodes.Add(F, F.Split("\")(F.Split("\").Length - 1)) End If Next For Each F As String In Files If (System.IO.File.GetAttributes(F) And IO.FileAttributes.Hidden) <> IO.FileAttributes.Hidden Then Me.TreeView1.Nodes.Add(F, F.Split("\")(F.Split("\").Length - 1)) End If Next
you can use something simillar to this code. this code only adds files and folders under the c:\ directory. you can extend this code to add other files under each folder. the best way is to make the function a recursive function but this will make your program very very slow. what i suggest is call this function everytime a node is clicked this add the childern of that node using this function. the nodes.add function can be extended to include icons to differ between a file and a folder. to add a child node you can use the following line:me.TreeView1.Nodes.Item(me.TreeView1.Nodes.IndexOfKey(Key)).Nodes.Add()
where the key is what i specified in the first argument of the Nodes.add line (= F) hope this helps, if you need further help please let me know Khalid -
Dim Files() As String = System.IO.Directory.GetFiles("c:\") Dim Folders() As String = System.IO.Directory.GetDirectories("C:\") For Each F As String In Folders If (System.IO.File.GetAttributes(F) And IO.FileAttributes.Hidden) <> IO.FileAttributes.Hidden Then Me.TreeView1.Nodes.Add(F, F.Split("\")(F.Split("\").Length - 1)) End If Next For Each F As String In Files If (System.IO.File.GetAttributes(F) And IO.FileAttributes.Hidden) <> IO.FileAttributes.Hidden Then Me.TreeView1.Nodes.Add(F, F.Split("\")(F.Split("\").Length - 1)) End If Next
you can use something simillar to this code. this code only adds files and folders under the c:\ directory. you can extend this code to add other files under each folder. the best way is to make the function a recursive function but this will make your program very very slow. what i suggest is call this function everytime a node is clicked this add the childern of that node using this function. the nodes.add function can be extended to include icons to differ between a file and a folder. to add a child node you can use the following line:me.TreeView1.Nodes.Item(me.TreeView1.Nodes.IndexOfKey(Key)).Nodes.Add()
where the key is what i specified in the first argument of the Nodes.add line (= F) hope this helps, if you need further help please let me know KhalidDear Sir I thank you very much I know how to fill tree and I use the following
Dim aDriveAs String For Each aDrive In Directory.GetDirectories("E:\") If (File.GetAttributes(aDrive) And IO.FileAttributes.Hidden) <> IO.FileAttributes.Hidden Then T.Nodes(0).Nodes.Add(aDrive) End If Next
But I need the following When I select folder from tree I want to display All files and Folders on a panel or somthing like this,i.e. in the same way as (windows explorer) so I can Open,Copy or delete any file or folder Thank you again -
Dear Sir I thank you very much I know how to fill tree and I use the following
Dim aDriveAs String For Each aDrive In Directory.GetDirectories("E:\") If (File.GetAttributes(aDrive) And IO.FileAttributes.Hidden) <> IO.FileAttributes.Hidden Then T.Nodes(0).Nodes.Add(aDrive) End If Next
But I need the following When I select folder from tree I want to display All files and Folders on a panel or somthing like this,i.e. in the same way as (windows explorer) so I can Open,Copy or delete any file or folder Thank you againi am not sure if i understod you correctly but you can use the AfterSelect event of the treeview control and you can get the name of the node by using the following line MsgBox(e.Node.Text) but for your code, it will be harder to read because you are including the entire path of each file which makes it hard for the user. What i suggest is use the same code as mine (add only the name of the file and use the Name property of the node to store the whole path. if you do this, then you would have to use the line: MsgBox(e.Node.Name) instead of the first one. after you get the path of the selected node, then you can use a list view control to display files and folders and do whatever you want to do with them. hope this makes things more clear. Khalid
-
i am not sure if i understod you correctly but you can use the AfterSelect event of the treeview control and you can get the name of the node by using the following line MsgBox(e.Node.Text) but for your code, it will be harder to read because you are including the entire path of each file which makes it hard for the user. What i suggest is use the same code as mine (add only the name of the file and use the Name property of the node to store the whole path. if you do this, then you would have to use the line: MsgBox(e.Node.Name) instead of the first one. after you get the path of the selected node, then you can use a list view control to display files and folders and do whatever you want to do with them. hope this makes things more clear. Khalid
Dear Sir Ithank You and I am Very Sory But Now my problem is can I use a list view control to display files and folders and do whatever you want to do with them. I need to know how can I display files and folders as larg icons
-
Dear Sir Ithank You and I am Very Sory But Now my problem is can I use a list view control to display files and folders and do whatever you want to do with them. I need to know how can I display files and folders as larg icons
to add items you just need to call ListView1.Items.Add("aa" ,0) to add an item called "aa" with icon index of 0 the index of the icons is found from an ImageList control that you have to add and insert images into. after adding the ImageList, you have to specify the Me.ListView1.LargeImageList = Me.ImageList1 to define the large images of the items and then change the image size in the ImageList to 32,32. by default, the ListView control displays LargeIcons (after setting up the steps before) but just in case you have to specify the propoprty ListView1.View = View.LargeIcon hope this helps you.. Khalid