473,473 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Odd ShowDialog problem

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
7 1710
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Richard L Rosenheim | last post by:
I would like to detect when a form is invoked as the result of a ShowDialog call. Anyone have any ideas or suggestions on how to do that? TIA, Richard Rosenheim
4
by: Dennis Sjogren | last post by:
Greetings! First, I'm not 100% sure where to post this question. I use VB.NET for this project, but it's really a design question (a question on which method to use when solving this problem). ...
6
by: Samuel R. Neff | last post by:
I'm having weird results with a form that is already displayed modally (via ShowDialog) displaying a second form via ShowDialog. The last form is not modal even though it's called with ShowDialog....
3
by: Richard L Rosenheim | last post by:
I would like to detect when a form is invoked as the result of a ShowDialog call. Anyone have any ideas or suggestions on how to do that? TIA, Richard Rosenheim
8
by: Joe Duchtel | last post by:
Hello - I have the following code to detemine a file name when my application is saving a file. The problem is that if the file already exists and I select the Yes button in the "Do you want to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.