Home All Groups Group Topic Archive Search About

Returning the button pressed from a FolderBrowserDialog

Author
20 Dec 2006 7:17 PM
OutdoorGuy
Greetings,

I have the following code in a VB.NET Windows application and was
wondering if there is any way to determine whether or not the user
pressed the "Cancel" button on the FolderBrowerseDialog?

Me.FolderBrowserDialog1.ShowDialog()

I tried dimensioning "x" as a boolean variable and using the statement
below, but it returned "true" regardless of what button was pressed.
Any ideas?

x = Me.FolderBrowserDialog1.ShowDialog()

Thanks in advance!



*** Sent via Developersdex http://www.developersdex.com ***

Author
20 Dec 2006 8:11 PM
Stephany Young
Ummmmmmmmm ...

  If Me.FolderBrowserDialog1.ShowDialog() = DialogResult.Cancel Then
    ...
  End If


"OutdoorGuy" <Outdoor***@fishing.com> wrote in message
news:%23RuC1tGJHHA.4712@TK2MSFTNGP04.phx.gbl...
Greetings,

I have the following code in a VB.NET Windows application and was
wondering if there is any way to determine whether or not the user
pressed the "Cancel" button on the FolderBrowerseDialog?

Me.FolderBrowserDialog1.ShowDialog()

I tried dimensioning "x" as a boolean variable and using the statement
below, but it returned "true" regardless of what button was pressed.
Any ideas?

x = Me.FolderBrowserDialog1.ShowDialog()

Thanks in advance!



*** Sent via Developersdex http://www.developersdex.com ***
Author
20 Dec 2006 8:15 PM
Mudhead
If FolderBrowserDialog1.ShowDialog() = 2 Then
       Debug.WriteLine("canceled")
Else
' -- Whatever
End If
  "OutdoorGuy" <Outdoor***@fishing.com> wrote in message news:%23RuC1tGJHHA.4712@TK2MSFTNGP04.phx.gbl...
  Greetings,

  I have the following code in a VB.NET Windows application and was
  wondering if there is any way to determine whether or not the user
  pressed the "Cancel" button on the FolderBrowerseDialog?

  Me.FolderBrowserDialog1.ShowDialog()

  I tried dimensioning "x" as a boolean variable and using the statement
  below, but it returned "true" regardless of what button was pressed.
  Any ideas?

  x = Me.FolderBrowserDialog1.ShowDialog()

  Thanks in advance!



  *** Sent via Developersdex http://www.developersdex.com ***
Author
20 Dec 2006 8:38 PM
OutdoorGuy
Thanks.  That worked great!


*** Sent via Developersdex http://www.developersdex.com ***
Author
20 Dec 2006 8:58 PM
Herfried K. Wagner [MVP]
"OutdoorGuy" <Outdoor***@fishing.com> schrieb:
> I have the following code in a VB.NET Windows application and was
> wondering if there is any way to determine whether or not the user
> pressed the "Cancel" button on the FolderBrowerseDialog?
>
> Me.FolderBrowserDialog1.ShowDialog()

\\\
Imports WinForms = System.Windows.Forms
....
If _
    Me.FolderBrowserDialog1.ShowDialog() = _
    WinForms.DialogResult.Cancel _
Then
    ...
End If
///

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>