![]() |
![]() |
|||
![]() |
![]() |
![]() ![]() by Caspar Boekhoudt Introduction It has recently come to my attention that there are quite a few people that have questions on how to develop a FolderDialog or how to add a directory list to a Windows Form. The purpose of this article is to give a simple example showing how easy it is to create a custom FolderDialog. This class was developed using VS.NET final release. ![]() Adding "DriveListBox","DirListBox", and "FileListBox" to VS.NET Toolbox Right Click "Toolbox" When the user selects a drive from the driveListBox drop-downlist, this method updates the path of the dirListBox to be consistent with the driveListBox. If the drive is unavailable, a MessageBox is presented to the user with the error, and the driveListBox.Drive is restored to its original selection.
private void driveListBox_SelectedIndexChanged(object sender, System.EventArgs e) When the user double-clicks on a folder, or the dirListBox is updated because the drive was changed, this method updates the Path of the fileListBox to be consistent with the dirListBox. If the directory is unavailable, a MessageBox is presented to the user.
private void dirListBox_Change(object sender, System.EventArgs e) The directory path selected
public string Path To use the FolderDialog, add the following code to your class. If the user hits the select button, it returns the folder path.
FolderDialog folderDialog = new FolderDialog(); Caspar Boekhoudt is a Consultant for Information Methodologies Inc. (imi), higher ed's leading enterprise web integrator. He has a M.S. in Computer Science and is a Sun Certified Programmer for the Java 2 Platform and IBM Certified Developer, XML and Related Technologies V1.
This article originally published at
C# Corner.
|
![]() |
|
![]() |