Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Open folder dialog - was there a solution?

29 views
Skip to first unread message

Hans Kristiansen

unread,
Feb 2, 2003, 11:51:49 AM2/2/03
to
Was there ever an answer to this question? I.e: How to display an "Open
FOLDER" dialog box/picker?

Thanks,
Hans


"news.microsoft.com" <drew.b...@softwareag.ca> skrev i en meddelelse
news:#m1sBgJvCHA.2060@TK2MSFTNGP11...
> Agreed.:
>
> The openfiledialog will not do. It lists files and you can't select a
folder
> to open, only files. As well the "Folder" combobox is missing.
>
> Is there an API to display the dialog used in the .net IDE or do I have to
> create my own?
>
>
> I've attached a copy of the dialog I'm looking for
>
>
> "Randy" <Ran...@email.com> wrote in message
> news:bgVU9.32360$hE3.2...@news1.west.cox.net...
> > Elena,
> >
> > This works great for selecting files, but when it comes to selecting a
> > folder it just blows.
> >
> > What is the deal anyway? We had a directory picker in VB6. It's
obvious
> > that VB .NET which runs on dot net has a folder dialog box.
> >
> > How would one go about using it?
> >
> > Randy
> >
> >
> > "VBDotNet Team [MS]" <vbdo...@microsoft.com> wrote in message
> > news:uT#fND0uCHA.1632@TK2MSFTNGP12...
> > > You can use the OpenFileDialogClass
> > > Dim openFileDialog1 As New OpenFileDialog()
> > >
> > > Elena Arzac
> > > VBDotNet Team
> > >
> > > --
> > > This posting is provided "AS IS" with no warranties, and confers no
> > rights.
> > > "news.microsoft.com" <drew.b...@softwareag.ca> wrote in message
> > > news:uHGqAmyuCHA.2596@TK2MSFTNGP12...
> > > > Does anybody know where / how to create an open folder dialog
similar
> to
> > > the
> > > > one used in the .net IDE?
> > > > (file->new->project -> browse)
> > > >
> > > >
> > >
> > >
> >
> >
>
>
>

Kaoru Kodaka

unread,
Feb 2, 2003, 12:13:16 PM2/2/03
to
Hans,

On Sun, 2 Feb 2003 17:51:49 +0100
"Hans Kristiansen" <h...@datamagic.dk> wrote:

inline...

> Was there ever an answer to this question? I.e: How to display an "Open
> FOLDER" dialog box/picker?

The answer is you should use SHBrowseForFolder() API. You
can acquire some component which is encapsulation for it.

Or wait next version of .NET Framework. It includes Folder
browser object.

---
| aMailAddress |
aMailAddress := 'ka...@venus.dti.ne.jp'.

Corrado Cavalli [MVP]

unread,
Feb 2, 2003, 4:44:28 PM2/2/03
to
Class BrowseForFoldersDialog
Dim m_Description As String

Property Description() As String
Get
Return m_Description
End Get
Set(ByVal Value As String)
m_Description = Value
End Set
End Property

Dim m_Path As String

Property Path() As String
Get
Return m_Path
End Get
Set(ByVal Value As String)
m_Path = Value
End Set
End Property

Function ShowDialog() As System.Windows.Forms.DialogResult
Dim fb As New FolderBrowser(Me)
Return fb.ShowDialog()
End Function

Private Class FolderBrowser
Inherits System.Windows.Forms.Design.FolderNameEditor

Dim parent As BrowseForFoldersDialog

Sub New(ByVal parent As BrowseForFoldersDialog)
Me.parent = parent
End Sub

Function ShowDialog() As System.Windows.Forms.DialogResult
Dim fb As New _
System.Windows.Forms.Design.FolderNameEditor.FolderBrowser()
fb.Description = parent.m_Description
ShowDialog = fb.ShowDialog()
If ShowDialog = Windows.Forms.DialogResult.OK Then
parent.m_Path = fb.DirectoryPath
End If
End Function
End Class

End Class


HTH

--
Corrado Cavalli [Microsoft MVP]
UGIdotNET - http://www.ugidotnet.org


Hans Kristiansen

unread,
Feb 3, 2003, 7:12:15 AM2/3/03
to
Thanks a million!

Sorry about the newbie question here, but:
Why do I get the following build error when I try to build a solution with
your provided class: "Type 'System.Windows.Forms.Design.FolderNameEditor' is
not defined."?

I can see that, according to the documentation, "FolderNameEditor" should be
a part of "System.Windows.Forms.Design", but I can't find it in the object
browser or elsewhere. What gives?

I'm using .net 2002 with framework 1.0 sp2 (1.0.3705).

Thanks,
Hans.

"Corrado Cavalli [MVP]" <corradoNO...@mvps.org> skrev i en meddelelse
news:uAS4oRwyCHA.2696@TK2MSFTNGP11...

Kaoru Kodaka

unread,
Feb 3, 2003, 8:00:52 AM2/3/03
to
Hans,

On Mon, 3 Feb 2003 13:12:15 +0100
"Hans Kristiansen" <h...@datamagic.dk> wrote:

inline...

> Thanks a million!

I don't think this solution is best. You can find better
solution in microsoft.public.dotnet.languages.csharp. Please
check next post.

oj

unread,
Feb 3, 2003, 4:42:19 PM2/3/03
to
Hans,

1. You need to add a reference to "System.Design" (system.design.dll).
2. You could try this...

Imports System.Windows.Forms.Design

Public Class OpenDirectoryDialog
Inherits FolderNameEditor

Dim _Description As String = "Please select a directory below:"
Dim _Path As String = String.Empty
Dim fb As New FolderBrowser()

Public Property Description() As String
Get
Return _Description


End Get
Set(ByVal Value As String)

_Description = Value
End Set
End Property

Public ReadOnly Property Path() As String
Get
Return _Path
End Get
End Property

Public Function ShowBrowser() As System.Windows.Forms.DialogResult
With fb
.Description = _Description
.StartLocation = FolderNameEditor.FolderBrowserFolder.MyComputer
Dim result As DialogResult = .ShowDialog
If result = DialogResult.OK Then
_Path = .DirectoryPath
Else
_Path = String.Empty
End If
Return result
End With
End Function
End Class


'Usage:
Dim d As New OpenDirectoryDialog()
With d
If .ShowBrowser = DialogResult.OK Then
txtDirectory.Text = .Path
End If
End With

--
-oj
RAC v2.1 & QALite are now RELEASED!!!
http://www.rac4sql.net

"Hans Kristiansen" <h...@datamagic.dk> wrote in message
news:#J2mw13yCHA.2512@TK2MSFTNGP11...

Hans Kristiansen

unread,
Feb 4, 2003, 8:02:55 AM2/4/03
to
Thank you very much, oj - works like a charm!

Best,
Hans


"oj" <nospam...@home.com> skrev i en meddelelse
news:OQieY08yCHA.2368@TK2MSFTNGP12...

0 new messages