(VB BUG?) Testing Folder & File Browser ...
NEWBIE ALERT!!!
Esteemed Forum Participants and Lurkers:
I an making my first attempt at using Folder and File selection Dialog Boxes. I know that I do not have to use BOTH, but I'm just playing with this primitive test just want to see how they both work.
I have one panel with one text box for the File Spec. Just to get started, double clicking on the text box is the event to open the path and then the file selection dialogs.
It all seems to work EXCEPT ... the Folder Dialog box SHOWS the "New Folder" button, and the code sets
ShowNewFolderButton = False.
I can NOT get the dialog to pop up without the New Folder button.
Here is the code:
Code:
' Text Box Component for File Name Selection
Private Sub q_SourcePath_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles q_SourcePath.DoubleClick
' Create an instance of the Folder Browser Popup Modal Dialog Box
Dim FolderBrowserDialog1 As New FolderBrowserDialog
' Create an instance of the File Browser Popup Modal Dialog Box
Dim OpenFileDialog1 As New OpenFileDialog
' SETUP THE FOLDER BROWSER
' This is the descriptive text in the Folder Select Dialog Box
FolderBrowserDialog1.Description = "Select the Folder where the files are located"
' This is the default path for the Folder Browser
FolderBrowserDialog1.SelectedPath = "C:\Test\MyFiles\"
' Do NOT allow a new folder to be created in this dialog
FolderBrowserDialog1.ShowNewFolderButton = False
' SETUP THE FILE BROWSER
' OpenFileDialog1.ShowHelp = False (False is the default)
' OpenFileDialog1.DefaultExt = "pdf" (Do this with the filter)
' Select only PDF files
OpenFileDialog1.Filter = "Select ONE prototype file|*.pdf"
' Do NOT allow selection of multiple files
OpenFileDialog1.Multiselect = False
' Execute the Folder Browser
If FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then
' Put the selected Folder path in the Source Path Text Box
q_SourcePath.Text = FolderBrowserDialog1.SelectedPath
End If
' Pass the Folder path to be the default path for the File Browser
OpenFileDialog1.InitialDirectory = q_SourcePath.Text
' Execute the File Browser
If OpenFileDialog1.ShowDialog = DialogResult.OK Then
' Put the selected File Spec in the Source Path Text Box
q_SourcePath.Text = OpenFileDialog1.FileName
End If
' To do or not to do ... that is the question.
' These lines are probably totatlly superfluous since the instances
' of the Dialog boxes are local to this subroutine.
FolderBrowserDialog1.Dispose()
OpenFileDialog1.Dispose()
End Sub
I would appreciate any and all comments regarding this snippet, ESPECIALLY why the "NewFolderButton" persists when it is supposed to be "OFF".
Testing Folder & File Browser Popups ... Version Bug?
MrPolite ...
You wrote:
>> hmm so you're saying that using the code above, a Make New Folder button DOES appear in your first dialog? because it does not appear for me either when I run that code <<
Hmm ... not only am I saying that, but I even created a brand new project ... 1 form ... 1 text box ... double clicked on the development text box to get into the code editor, selected the double click event and generated the double click handler code, and cut and pasted the code right out of my post into the handler. I changed 3 instances of the component.text property to "TextBox1.text" because I left the name of the textbox as the default "TextBox1".
Guess what ... I hit F5 and double click the text box, and I STILL get the "New Folder" button on the folder dialog popup, and clicking it created the next sequential "New Folder (4)"!!!
I just tried it again this morning, and here is what I cut and pasted out of TextBox1 after going through both dialogs ...
C:\Test\MyFiles\New Folder (5)
How's that for weird?
Microsoft Development Environment 2003 v7.1.3088
Microsoft .NET Framework 1.1 v1.1.4322