Multiple Windows without MDI (Continued)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

With an application with more than one window I can display another windo

Form2 f2 = new Form2()
f2.Show()

However when I want to return to form1 what do I need to do

I tried to use Activate, but it didn't wor
if I do as I did above a new form is instantiated
 
Morten,

I tried to use BringToFront using Form1.BringToFront() but I get an error

An object reference is required for the nonstatic field, method, or property 'System.Windows.Forms.Control.BringToFront(

Phil
 
That means the Form you are trying to Bring to Front does not exist. For Form2 to be able to call Form1 you need to give it a reference to Form1.

Happy coding!
Morten Wennevik [C# MVP]
 
Hi Morten

I am sorry but I am new to this language and I don't understand how to give form2 a reference to form 1. I greatly appreciate you patience and your help.
 
=?Utf-8?B?cHNmZWxpY2U=?= said:
I am sorry but I am new to this language and I don't understand how to
give form2 a reference to form 1. I greatly appreciate you patience and
your help.

Your question isnt very specific. There are several ways to do this. If you
only have one instance for form1 you can make a static and store it there.




--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Get your ASP.NET in gear with IntraWeb!
http://www.atozed.com/IntraWeb/
 
Chad

I am writing an application that would have several windows. However I want to be able to return from any window back to the main window. Can you provide a quick example of what you mean

Thanks Phil
 
=?Utf-8?B?UGhpbA==?= said:
I am writing an application that would have several windows. However I
want to be able to return from any window back to the main window. Can
you provide a quick example of what you mean?

I dont have time to write a demo - but look up how to create static members.
You can use that to store a reference and use it to reshow the forms.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/
 
Back
Top