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

Home Posts Topics Members FAQ

windows form close and open next form

Hi all

Just i want to close the form1 when i click the button1 on form1 and
the same time i want to load the form2 on the same event.
And i dont want to hide the form1 instead of close. Please post some
piece of coding

For the above i am using c# windows forms

Thanks

May 4 '06 #1
5 45920

Sudha,
The first thing you need to do is open Form2 BEFORE closing Form 1

Just create a new instance and show it:
Frm2 = new Form2()
Frm2.Show();
You can then call Close(), or close form 1 from the Load event of Form 2;
Paul Cheetham

Sudha Pune wrote:
Hi all

Just i want to close the form1 when i click the button1 on form1 and
the same time i want to load the form2 on the same event.
And i dont want to hide the form1 instead of close. Please post some
piece of coding

For the above i am using c# windows forms

Thanks

May 4 '06 #2
Hi paul

Thanks for ur reply,

If i close the form1 after opening the form2 then both forms are
getting closed

in the second way,
how will i get form1 reference on form2, i am able to create new form1
in form2, but i dont have any idea to get the existing form1 reference
on form2, can u tell me

please solve this issue

Thanks

Paul Cheetham wrote:
Sudha,
The first thing you need to do is open Form2 BEFORE closing Form 1

Just create a new instance and show it:
Frm2 = new Form2()
Frm2.Show();
You can then call Close(), or close form 1 from the Load event of Form 2;
Paul Cheetham

Sudha Pune wrote:
Hi all

Just i want to close the form1 when i click the button1 on form1 and
the same time i want to load the form2 on the same event.
And i dont want to hide the form1 instead of close. Please post some
piece of coding

For the above i am using c# windows forms

Thanks


May 5 '06 #3
> If i close the form1 after opening the form2 then both forms are
getting closed


If form1 is your main form (i.e. the form displayed when your application
starts) then closing that form will, by default, close your application. I
believe it is possible to change this behaviour using the ApplicationContext
class, but I don't know the details - maybe someone else can help?

Chris Jobson
May 5 '06 #4
> If i close the form1 after opening the form2 then both forms are
getting closed


If form1 is your main form (i.e. the form displayed when your application
starts) then closing that form will, by default, close your application. I
believe it is possible to change this behaviour using the ApplicationContext
class, but I don't know the details - maybe someone else can help?

Chris Jobson
May 5 '06 #5
The best way to do this is use MDIParent form and control all sub-forms from
that. Make the sub-forms fill the whole frame area.

form1.Close()
form2 = new Form2()
form2.ControlBox = false;
form2.Dock = DockStyle.Fill
form2.Show()

Sudha Pune wrote:
Hi all

Just i want to close the form1 when i click the button1 on form1 and
the same time i want to load the form2 on the same event.
And i dont want to hide the form1 instead of close. Please post some
piece of coding

For the above i am using c# windows forms

Thanks

May 7 '06 #6

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

Similar topics

1
5965
by: Bob Sanderson | last post by:
I have two forms, frmSearch and frmMain. I want to be able to enter a job number in a text box on frmSearch and when I enter it, open frmMain and go to the record for the job number I've entered....
2
1818
by: Zlatko Matić | last post by:
Hi. How to check whether some form is open or not, in VBA ? Thanks.
8
1285
by: Vivek | last post by:
Hi, I am using this code to open the form... --------------------------------------------------------------------------------------- Private frmAddUser as AddUser() Dim fc As Form For Each fc...
4
2093
by: hzgt9b | last post by:
Using VB .NET 2003, I have a windows application that performs a series of file actions (copy, move, delete) but the actions are completing before the window is painted on the screen... how can I...
3
10646
by: Ronald S. Cook | last post by:
I know how to close and open a form... Well.. but can you tell me how can I do this..... Example... There are 2 forms...named formA and formB and each of them have their own button named...
2
4391
by: RP | last post by:
I have a login form. I want to open the main MDI form if the login was successful and want to close the login form. I tried below code, but it is not working:...
3
2457
by: rajashekar4dotnet | last post by:
how to open one form from the other form and close the first form if there are only two forms in windows application(VB.net) i had tried this method dim f as new form2 form2.show( )...
3
4834
by: touf | last post by:
HI, In my windows application (VB.NET) when I open a form the memory is increasing but When I close it the memory doen't decrease (task manager). each time I close the form and re-open it the...
1
1618
by: rakabuku | last post by:
I'm really new with Acces and VBA, so all the help with code is greatly appreciated! I created a form that kind of works like a switchboard (FRM_A) with two combo boxes . Both boxes take the...
0
7123
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
7324
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,...
0
7382
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5627
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
5052
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
4707
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
3193
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
3181
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.