Hi bruintje,
I looked at this before, it didnt help much, i code on the webpage is incomplete and i tried to download the sample sourcecode, it asking for the registration.
so i left it.
any other sites.
regards
naren
Main Topics
Browse All TopicsHi Guys,
i need an example to move from form1 to form2
and back from form2 to form1.
example
from2.show
form1.hide.
i dont want to use the MDI,
any links would be appriciated
regards
naren
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Here is the simple way:
// Form1 property
private Form mCallerForm;
public Form CallerForm
{
set ( mCallerForm = value;}
}
// Form1 modified constructor
public Form1(Form caller)
{
mCallerForm = caller;
}
private void buttonMove_Click(object sender, EventArgs e)
{
mCallerForm.Show();
this.Hide();
}
Do the same thing with Form2.
Another way if you know extractly the form to move on, just create an instance of it and show. For example:
In Form1: Form2 frm = new Form2();
frm.Show();
this.Hide():
Hope this helps.
i think that using the second approach you could move from Form1 to Form2 but not from Form2 to Form1. When i need something like this i use the Owner property:
//Form1 code
private void btn1_Click(object sender, EventArgs e)
{
Form2 form2=new Form2();
form2.Owner=this;
this.Hide();
form2.Show();
}
//Form2 code
private void btn1_Click(object sender, EventArgs e)
{
((Form1)this.Owner).Show()
this.Hide(); //or this.Close();
}
Hi naren,
It might be easier to keep a seperate class which contains public static fields that hold references to your forms. That way you can access your form methods from any form instance. Try this:
Create a new class "Global":
public class Global
{
public static Form Form1Ref;
public static Form Form2Ref;
}
In your Form1 constructor, assign the reference to the Global field for Form1, i.e:
//Form1's constructor
public Form1()
{
...
Global.Form1Ref = this; //Assigning reference here
}
To get to Form2 you would have something like:
Form2 frm2 = new Form2();
Global.Form2Ref = frm2; //Assign Form2 reference to the global class field so that its easily available
Global.Form2Ref.Show(); //Use global reference to show Form2
Global.Form1Ref.Hide(); //Hide Form1
To get back to Form1 (from Form2) you would have:
Global.Form2Ref.Hide();
Global.Form1Ref.Show();
This way you won't lose any reference to each form (like you have in your previous post), i.e. you can show/hide continiously until the form objects have been disposed.
Hope this helps!
Business Accounts
Answer for Membership
by: bruintjePosted on 2006-01-02 at 22:03:17ID: 15596535
Hello r_naren22atyahoo,
om/winform s/BankingS ystemAH001 .asp
you could try something like
source: http://www.c-sharpcorner.c
--------------
Abstract: This article explicates the use of two major features of DOT NET. They are (i) Windows Forms and (ii) Data Base Connectivity. This article also focuses on deploying multiple windows forms and shows how to navigate between them. The best business application that explores these two features is a banking application and hence is the subject of this article.
--------------
hope this helps a bit
bruintje