473,500 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using multiple modal dialogs in a Windows app

Hello,

I have a Windows form that opens a modal dialog window. From there I
can open yet another modal dialog window so I can grab some info to
pass back to the first dialog. Both need to be modal and are launched
like this:
>From my main Windows form:
if (formName1.ShowDialog( this ) == DialogResult.OK)
......
>From formName1:
if (formName2.ShowDialog( this ) == DialogResult.OK)
......

I have OK buttons on both modal forms that return a DialogResult of OK
and then they do formName.Close(). They both also have a Cancel
button with simply a formName.Close().

My problem is when I close the second dialog window via either a
Cancel or OK, the first one closes with it, and I would like for the
first to stay open :)

Does anyone have any ideas?

Mike

Sep 6 '07 #1
1 3768
On 6 Sep., 04:42, Mike <mccar...@hotmail.comwrote:
Hello,

I have a Windows form that opens a modal dialog window. From there I
can open yet another modal dialog window so I can grab some info to
pass back to the first dialog. Both need to be modal and are launched
like this:
From my main Windows form:

if (formName1.ShowDialog( this ) == DialogResult.OK)
......
From formName1:

if (formName2.ShowDialog( this ) == DialogResult.OK)
......

I have OK buttons on both modal forms that return a DialogResult of OK
and then they do formName.Close(). They both also have a Cancel
button with simply a formName.Close().

My problem is when I close the second dialog window via either a
Cancel or OK, the first one closes with it, and I would like for the
first to stay open :)

Does anyone have any ideas?

Mike
I tried reproducing the problem you describe, but it seems to work
fine for me.
Creating 3 windows, each with a button with its DialogResult-Property
set to OK, the first one calling ShowDialog on the second and the
second on the third, behave exactly as expected.
Could you post a short program that still causes the unexpected
behavior?
As a sidenote: You don't actually have to call Close on the form
within a button's click-event if the button has a DialogResult
associated with it, the form will close automatically after the button
is pressed.

Kevin Wienhold

Sep 6 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
7136
by: Bjoern Obermeyer | last post by:
Hi, I am writing an application with a JFrame as the main window and several dialogs to gain user input. The problem arises when another window (from a differnent apllication) hides my...
3
2829
by: Andrew Baker | last post by:
OK this has me perplexed, puzzled and bamboozled! I have a remoting service which I displayed a message box in. I then wondered what would happen if a client made a call to the service while the...
5
3851
by: MrNobody | last post by:
I am using the no-arg ShowDialog() method hoping that the window would not be modal to any other window like the other ShowDialog(IWin32Window) method does, but when this opens it somehow becomes...
2
2543
by: cassidyc | last post by:
Hi, I was wondering if anyone has come accross this issue? And if they have any solutions I have that can create new copies of itself Form1 as = new form1(); af.show(); This form can also...
1
8054
by: SammyBar | last post by:
Hi all, I'm having troubles with a Symbol 9000 device (Compact Framework v 1.1) when activating the barcode scanner from a window. The problem is related to the Activated event of the form which...
2
3669
by: sthrudel | last post by:
Hi! I'm working on a web application in Asp.net and what I would like to have is a cross borwser modal dialog which accepts user's input. I would like to catch what the user clicked on the...
10
4811
by: bern11 | last post by:
If Form1 opens Form2 modally, how do I capture clicks on Form1 when Form2 is open? I want to click on Form1 and read the mouse co-ordinates into Form2. Since Form2 is open modally, Form1...
7
1578
by: proximus | last post by:
hello i need some modal dialog box to show when page is loaded any sugestion? not 'onclik' thanks -- www.proximus-os.hr ; www.e-stranica.com ; www.zlatovezi.com
1
3543
by: Mohit | last post by:
Hi all, I am working on a windows based client server application with multiple forms. All forms are having custom title bars with no default bars. There is one main form. Some forms are opened up...
0
7018
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
7397
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...
0
5490
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4923
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
4611
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
3110
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
1430
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
672
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
316
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.