MessageBox

  • Thread starter Thread starter Patrick De Ridder
  • Start date Start date
P

Patrick De Ridder

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.
 
Hi,

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

Form1.Close();



Alan
 
On Tue, 5 Aug 2003 14:25:38 +0100, "Alan Gilmour" <a.gilmour
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,

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
 
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.
 
Back
Top