![]() |
Languages »
VB.NET »
General
Intermediate
Files Selection Dialog Box /TREE/By Alaa JebranTREE VIEW DIALOG BOX |
VB 8.0, Windows, .NET 2.0VS2005, Dev
|
||||||||
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
The problem is this : programmers are not allowed to inherit the files dialog boxes in vb.net2005
and there are two kinds : open and save.
once ago, I made an encryption program that worked like a safe
for personal data ,in my program there were buttons named: import and export
and I thought it is ugly to use dialogs with buttons whose caption is (save ,open)
so I know some people will need to change buttons' captions in certain situations.
This project is good for those who want to design a customized file dialog box
It contains an implementation of three " tree view " file dialog boxes
first one uses microsoft files-folders tools .
second one is a simple dialog that will show a file description of any file you select.
the third one is a rich dialog with progress bar , movable menu , status bar and multiple view choices :
details ,list, larg icons ...
basic knowledge of the language and tree-list view controls .
import all code files of the dialog you like in your project and
Just handle the files in the code of "proceed" button instead of showing msgbox of them.
I will not explain everythings but only the headlines:
when you load the form ,the program will use Directory.GetLogicalDrives to take
all the drives in your computer ,and will add them in the tree view control , an image list is needed here to set
small icons for the list of drives
now we will need a procedure to get one level folders to handle the click on any node (after select event)
this procedure will take the name of the node ( drive or folder ) and will display the childs of this node
according to the names of the nested folders of that drive or folder and will display the files of it in the list view
control and two image lists are needed here because of the two views (larg icons,small icons) and you must bind them to the list control ,here are the main procedures :
// this will generate one level of folders in the tree node // itree is the mother node and path is logical path on hard disk that this node stands for. // Sub printfilesfolders_here(ByVal path As String, ByRef itree As TreeNode) //Dim foldername As String //Dim filename As String //itree.Nodes.Clear() //On Error GoTo eee //For Each foldername In Directory.GetDirectories(path) ''take the name of folders in the folder or drive // On Error GoTo eee // Dim jj = foldername.LastIndexOf("\") //Dim jj1 = foldername.Length - jj //Dim foldr = foldername.Substring((jj + 1), (jj1 - 1))'separate the name from the path // itree.Nodes.Add(foldr, foldr) 'add only the name //Next Exit Sub // eee: //End Sub // //this will display files in the list view according to the path of the mother node //Sub displayfiles(ByVal path As String) //it uses for each on Directory.GetFiles //to take the pathes of files and then it gets only the names and adds them // in the list //we use AddRange instead of add to gain the details view in the list
If you shell the dialog after you add a usb flash disk or a new Network place they will not appear
so you may plan to add a refresh button.
last updated: 2-4-2007
| You must Sign In to use this message board. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 8 May 2007 Editor: |
Copyright 2007 by Alaa Jebran Everything else Copyright © CodeProject, 1999-2009 Web21 | Advertise on the Code Project |