Click here to Skip to main content
6,306,412 members and growing! (17,258 online)
Email Password   helpLost your password?
Languages » VB.NET » General     Intermediate

Files Selection Dialog Box /TREE/

By Alaa Jebran

TREE VIEW DIALOG BOX
VB 8.0, Windows, .NET 2.0VS2005, Dev
Posted:8 May 2007
Views:19,658
Bookmarked:19 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
20 votes for this article.
Popularity: 4.69 Rating: 3.61 out of 5
3 votes, 15.0%
1
1 vote, 5.0%
2
1 vote, 5.0%
3
4 votes, 20.0%
4
11 votes, 55.0%
5

Screenshot - Article.gif

Introduction

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 ...

Background

basic knowledge of the language and tree-list view controls .

Using the code

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



Points of Interest

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.

History

last updated: 2-4-2007

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Alaa Jebran


Member
IT degree ,Damascus informatics academy
especiality : AI
Personal Interests: .net programming , DB , image processing and Steganography.


Occupation: Technical Writer
Company: Code Project
Location: Syrian Arab Republic Syrian Arab Republic

Other popular VB.NET articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 11 of 11 (Total in Forum: 11) (Refresh)FirstPrevNext
GeneralNIcely Done Pinmemberapache1o23:48 11 Jun '07  
QuestionI have a private question Pinmembercommandant_.4:40 16 May '07  
Generalyou are extremely bright [modified] Pinmembercommandant_.4:35 16 May '07  
GeneralWhat abt VS 2003 PinmemberPradeep Sen21:11 14 May '07  
AnswerRe: What abt VS 2003 PinmemberAlaa Jebran10:35 15 May '07  
Generalrequest: PinmemberRola saad22:58 8 May '07  
GeneralRe: request: PinmemberAlaa Jebran0:16 9 May '07  
GeneralRe: request: PinmemberAlaa Jebran0:17 9 May '07  
Generalgreat! PinmemberRola saad22:50 8 May '07  
Generalwould you? PinmemberAndromeda ..22:11 8 May '07  
GeneralRe: would you? PinmemberAlaa Jebran0:15 9 May '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 8 May 2007
Editor:
Copyright 2007 by Alaa Jebran
Everything else Copyright © CodeProject, 1999-2009
Web12 | Advertise on the Code Project