473,666 Members | 2,392 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 45938

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 ApplicationCont ext
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 ApplicationCont ext
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.ControlBo x = 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
5967
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. This seems fairly simple but I haven't been able to get it to work properly. Here's the code in frmSearch. txtSearch is the input text box and JobNumber is the field I want to select frmMain by. Private Sub txtSearch_Exit(Cancel As Integer)...
2
1822
by: Zlatko Matić | last post by:
Hi. How to check whether some form is open or not, in VBA ? Thanks.
8
1295
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 In Me.MdiParent.MdiChildren If fc Is frmAddUser Then
4
2100
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 force the form to be painted on the screen first, then the actions start? Or should I pause the app for a few seconds while the form paints. Any suggestion woudl be appreciated!
3
10661
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 btnA and btnB The application starts with formA
2
4398
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: ====================================== private void OK_Click() { //If login successful try { MainForm MainWindow = new MainForm();
3
2459
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( ) me.close( )
3
4851
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 memory is increasing. with the time the machine (512 MO) become slow. Is there a way to release the memory when closing the form. Thanks
1
1625
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 information from Table_A. This form has a “Search” button. See attached PDF file DB 1. When I hit the “Search” button it will open a second form (FRM_B). Form FRM_B is supposed to open for the corresponding “Staff Initials”. Form FRM_B has the...
0
8352
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8863
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8636
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6189
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4192
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4358
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2765
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 we have to send another system
2
2005
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1763
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.