473,508 Members | 2,454 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MessageBox

I have two forms: Form1 and Form2.

In Form2 I have an OK/Cancel MessageBox.

I have coded

if(result==DialogResult.Cancel) Close();

That returns the user to Form1.

I want to return to Form2 instead of to Form1.

Please help me by giving the statement with which to replace Close().

Many thanks.

--
Patrick De Ridder
ng****@freeler.nl


Nov 15 '05 #1
4 15541
Hi,

Your description was a bit vague but can you not just use the object for
Form1 and then call

Form1.Close();

Alan
"Patrick De Ridder" <ng****@freeler.nl> wrote in message
news:ld********************************@4ax.com...
I have two forms: Form1 and Form2.

In Form2 I have an OK/Cancel MessageBox.

I have coded

if(result==DialogResult.Cancel) Close();

That returns the user to Form1.

I want to return to Form2 instead of to Form1.

Please help me by giving the statement with which to replace Close().

Many thanks.

--
Patrick De Ridder
ng****@freeler.nl

Nov 15 '05 #2
On Tue, 5 Aug 2003 14:25:38 +0100, "Alan Gilmour" <a.gilmour
no****@locland.com> wrote:
Hi,

Your description was a bit vague but can you not just use the object for
Form1 and then call

Form1.Close();


Nope.

Form2 is a form in which I enter data to be written away.
At a certain point a message box appears with Ok/Cancel.
When I press Cancel I want to return to Form 2, not to Form1.

I know how to return to Form1 (Close() will do the trick).

Any more suggestions?

--
Patrick De Ridder
ng****@freeler.nl
Nov 15 '05 #3
Patrick,

When you call Close() aren't you closing the form (Form2) that
you want to return to?

If you call MessageBox.Show() with Form2 set as owner, Form2
will be reactivated when the message box closes. You don't need
to call any method to close the message box itself, it will be
automatically closed when the user clicks one of its buttons.

I might have misunderstood the problem.

- Magnus
"Patrick De Ridder" <ng****@freeler.nl> wrote in message
news:im********************************@4ax.com...
On Tue, 5 Aug 2003 14:25:38 +0100, "Alan Gilmour" <a.gilmour
no****@locland.com> wrote:
Hi,

Your description was a bit vague but can you not just use the object for
Form1 and then call

Form1.Close();


Nope.

Form2 is a form in which I enter data to be written away.
At a certain point a message box appears with Ok/Cancel.
When I press Cancel I want to return to Form 2, not to Form1.

I know how to return to Form1 (Close() will do the trick).

Any more suggestions?

--
Patrick De Ridder
ng****@freeler.nl

Nov 15 '05 #4
On Tue, 5 Aug 2003 20:05:15 +0200, "Magnus Krisell"
<ma******@NOSPAMstudent.liu.se> wrote:

When you call Close() aren't you closing the form (Form2) that
you want to return to?

If you call MessageBox.Show() with Form2 set as owner, Form2
will be reactivated when the message box closes. You don't need
to call any method to close the message box itself, it will be
automatically closed when the user clicks one of its buttons.

I am calling the message box from within a button click handler and
want to return to the form in which the button is placed.

I am aware that after leaving a message box you return to the form
proper, but that is not the problem here.

--
Patrick De Ridder
ng****@freeler.nl
Nov 15 '05 #5

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

Similar topics

11
541
by: Rich Tasker | last post by:
I have a strange situation. A simple call to MessageBox.Show("XXX", "YYY") does not display the message in the messagebox with a visible font. Based on the content of the messagebox, the box...
8
13090
by: Dennis C. Drumm | last post by:
I have ordered the book .NET Framework Solutions, In Search of the Lost Win32 API by John Paul Meuller which I think will help answer some of my questions I have regarding making custom...
2
30126
by: Dennis C. Drumm | last post by:
This is a restatement of an earlier post that evidently wasn't clear. I am building a custom MessageBox dialog that has, among other things, a few new button options (yes to all, no to all, etc.)...
8
2429
by: Saso Zagoranski | last post by:
Hi! I'm trying to make my own MessageBox... What I would like to know is, how the MessageBox class is implemented? I could have something like: new MyMessageBox().ShowDialog(); but I would...
4
1917
by: Tressa | last post by:
I have a messagebox that I only want to pop up only if it is not already being displayed on the screen. My code is still poping up the messagebox even though it is on the screen. What am I doing...
3
7410
by: Sin | last post by:
I'm currently evaluating VC.NET as the new platform for the company I work for and things are looking grim... We're up against another IDE which took me about 5 minutes to master and I've been...
0
4092
by: alex_f_il | last post by:
The class centers MessageBox inside the parent rectangle. Enjoy! using System; using System.Windows.Forms; using System.Text; using System.Drawing; using System.Runtime.InteropServices; ...
20
8859
by: Peter E. Granger | last post by:
I'm having a strange problem (or at least it seems strange to me) trying to display a MessageBox in a VC++ .NET forms application. If I put the call to MessageBox::Show in the form's .h file, it...
10
2324
by: Russ | last post by:
I've been trying to figure out how to show a simple messagebox with an OK button in my web client program (C#). I have looked at every reference to JScript and MessageBox that seemed even remotely...
4
1993
by: Larry Woods | last post by:
I have a Messagebox that looks like: MessageBox.Show("There are pending changes for this patient. Do you want to continue to close?", "Pending Changes", MessageBoxButtons.YesNo,...
0
7229
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7129
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
7333
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7061
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5637
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,...
0
3194
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1566
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
769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
428
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.