By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,767 Members | 1,073 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,767 IT Pros & Developers. It's quick & easy.

Odd ShowDialog problem

P: n/a
dgk
I'm showing a form using ShowDialog (VB2003 in Visual Studio), and a
button on that form pops up a FolderBrowserDialog. As soon as the FBD
is closed, either by selecting or by cancel, the form exits. Not the
behavior that I was hoping for. Did I mess something up or is this the
way that it works?
Nov 21 '05 #1
Share this Question
Share on Google+
7 Replies

P: n/a
dgk wrote:
I'm showing a form using ShowDialog (VB2003 in Visual Studio), and a
button on that form pops up a FolderBrowserDialog. As soon as the FBD
is closed, either by selecting or by cancel, the form exits. Not the
behavior that I was hoping for. Did I mess something up or is this the
way that it works?


Can we see some simplified code that shows the problem?

chris
Nov 21 '05 #2

P: n/a
dgk
On Sun, 31 Jul 2005 23:57:43 -0400, Chris <no@spam.com> wrote:
dgk wrote:
I'm showing a form using ShowDialog (VB2003 in Visual Studio), and a
button on that form pops up a FolderBrowserDialog. As soon as the FBD
is closed, either by selecting or by cancel, the form exits. Not the
behavior that I was hoping for. Did I mess something up or is this the
way that it works?


Can we see some simplified code that shows the problem?

chris

In the main form (during load if app settings aren't created yet):

Dim frmOptions As New frmOpts
Dim RCF As DialogResult = frmOptions.ShowDialog
If RCF = DialogResult.Cancel Then Environment.Exit(1)
frmOptions.Close()
In frmOptions I declare this:

Private FBD As New System.Windows.Forms.FolderBrowserDialog

and in a button click event do this:

Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnBrowse.Click

FBD.ShowNewFolderButton = True
Dim J As DialogResult = FBD.ShowDialog
End Sub

Click on the button, the Folder dialog pops up. Click either Ok or
Cancel and the folderbrowser exits, and so does the form. I can likely
stop it in OnClosing since that code is certainly firing, but I have
no idea why it is happening.
Nov 21 '05 #3

P: n/a
DGK,

How do you set that OK in your code.

Return dialogresult.OK as the button OK is clicked will probably fix the
job.

Be aware that there are some bugs in this by setting the button using the
designer to OK.
(I am not sure anymore what it was, so I never use this)

I hope this helps,

Cor
Nov 21 '05 #4

P: n/a
dgk
On Mon, 1 Aug 2005 07:06:19 +0200, "Cor Ligthert [MVP]"
<no************@planet.nl> wrote:
DGK,

How do you set that OK in your code.

Return dialogresult.OK as the button OK is clicked will probably fix the
job.

Be aware that there are some bugs in this by setting the button using the
designer to OK.
(I am not sure anymore what it was, so I never use this)

I hope this helps,

Cor


I'm not sure that I understand this. I do set dialogresult.OK in the
OK button on the form, which is where the settings are actually
updated, but the OK that is from the FolderBrowserDialog is part of
the sealed class and I can't do anything about it. Apparently
selecting either button on the FBD object is somehow satisifying the
need for a dialog result for the form. But if that was so, I wouldn't
be the first one writing about it. I've looked through two years of
messages and there are quite a few on ShowDialog but none mention
this.
Nov 21 '05 #5

P: n/a
dgk wrote:
I'm showing a form using ShowDialog (VB2003 in Visual Studio), and a
button on that form pops up a FolderBrowserDialog. As soon as the FBD
is closed, either by selecting or by cancel, the form exits.


What is the DialogResult property of the button on your form set to? If it's
something other than None, this could result in the behaviour you described.

--

(O)enone

Nov 21 '05 #6

P: n/a
dgk
On Mon, 1 Aug 2005 13:30:48 +0100, "Oenone" <oe****@nowhere.com>
wrote:
dgk wrote:
I'm showing a form using ShowDialog (VB2003 in Visual Studio), and a
button on that form pops up a FolderBrowserDialog. As soon as the FBD
is closed, either by selecting or by cancel, the form exits.


What is the DialogResult property of the button on your form set to? If it's
something other than None, this could result in the behaviour you described.


I hadn't set the DialogResult to anything yet. I just tried setting it
to None in Load and still got the same behavior. So I made a new
project with just the essentials, one form showing another with
ShowDialog(Me) and having a button on that form pop up the
FolderDialogBrowser. It worked fine. So something else is weird in my
project. Maybe a custom control that I'm also using on that form is
causing problems? I'll gut it and see what happens.
Nov 21 '05 #7

P: n/a
dgk
On Mon, 01 Aug 2005 13:23:14 GMT, dgk
<so******************@zero-spam-hotmail.com> wrote:
On Mon, 1 Aug 2005 13:30:48 +0100, "Oenone" <oe****@nowhere.com>
wrote:
dgk wrote:
I'm showing a form using ShowDialog (VB2003 in Visual Studio), and a
button on that form pops up a FolderBrowserDialog. As soon as the FBD
is closed, either by selecting or by cancel, the form exits.


What is the DialogResult property of the button on your form set to? If it's
something other than None, this could result in the behaviour you described.


I hadn't set the DialogResult to anything yet. I just tried setting it
to None in Load and still got the same behavior. So I made a new
project with just the essentials, one form showing another with
ShowDialog(Me) and having a button on that form pop up the
FolderDialogBrowser. It worked fine. So something else is weird in my
project. Maybe a custom control that I'm also using on that form is
causing problems? I'll gut it and see what happens.

Ok, I have now added a new form and built the code back up until it is
a duplicate of the original problem form. It works fine. I have no
idea what is different but I'm on vacation today and I'M GOING TO THE
BEACH NOW. I just couldn't go until I had this fixed.
Nov 21 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.