473,395 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Opening and closing Form C#

Hi

In WinForms, I want to navigate from a form to another one. The problem is that he doesn't want to close the first Form when I do that.

Code

frmRecieve oForm = new frmRecieve ();
oForm.ShowDialog();

this.Close();

Anyone who can help? Thanks
Apr 15 '08 #1
5 2007
If u don't want to close first form(form1) when u navigate to onther form(form2)..
Write down following code.

Form2 frm=new Form2();
frm.showDialog();

This code work perfectly.Althought form2 display on screen but it is modal so u can't navigate to from1 untill u close from2.

Bye...Take Care....Enjoy Coding
Apr 15 '08 #2
Curtis Rutland
3,256 Expert 2GB
Hi

In WinForms, I want to navigate from a form to another one. The problem is that he doesn't want to close the first Form when I do that.

Code

frmRecieve oForm = new frmRecieve ();
oForm.ShowDialog();

this.Close();

Anyone who can help? Thanks
Expand|Select|Wrap|Line Numbers
  1. frmRecieve oForm = new frmRecieve ();
  2. //oForm.ShowDialog();
  3. //if you change this line to Show(), the forms can be switched back and forth.
  4. oForm.Show();
  5. //this.Close();
  6. //skip the Close() part to not close the current form.
  7.  
Also, if you want to be able to switch back and forth, but not be able to spawn multiple forms, set frmRecieve oForm as a public member of the parent form.
Then, when you want to bring it up,
Expand|Select|Wrap|Line Numbers
  1. if(oForm == null || oForm.IsDisposed)
  2. {
  3.   oForm = new frmRecieve();
  4.   oForm.Show();
  5. }
  6. else
  7.   oForm.Focus();
  8.  
Apr 15 '08 #3
Expand|Select|Wrap|Line Numbers
  1. frmRecieve oForm = new frmRecieve ();
  2. //oForm.ShowDialog();
  3. //if you change this line to Show(), the forms can be switched back and forth.
  4. oForm.Show();
  5. //this.Close();
  6. //skip the Close() part to not close the current form.
  7.  
Also, if you want to be able to switch back and forth, but not be able to spawn multiple forms, set frmRecieve oForm as a public member of the parent form.
Then, when you want to bring it up,
Expand|Select|Wrap|Line Numbers
  1. if(oForm == null || oForm.IsDisposed)
  2. {
  3.   oForm = new frmRecieve();
  4.   oForm.Show();
  5. }
  6. else
  7.   oForm.Focus();
  8.  
Thanks, but I want to close the first form, but he doesn't do that.
Apr 15 '08 #4
Curtis Rutland
3,256 Expert 2GB
Thanks, but I want to close the first form, but he doesn't do that.
Oh, I misunderstood that, sorry. I don't know off the top of my head. Let me think about it.
Apr 15 '08 #5
Oh, I misunderstood that, sorry. I don't know off the top of my head. Let me think about it.
I Finally figured it out

FrmTest oForm = new FrmTest();
oForm.ShowDialog();

this.Dispose(FALSE);

Thx anyway
Apr 17 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jean-Fran?ois Lacrampe | last post by:
Hello, I want to write a _very_ simple text parser that would replace a string like: "This is text with /italics/, *bold* and _underline_." and generate automatically something like this: ...
1
by: Eric Cadwell | last post by:
We're running Load Runner to test a large 1.0 based WinForms application. I'm getting the following exception when opening and closing a form 400 - 450 times. The form contains several controls and...
1
by: MJEASSOC | last post by:
I need some help with closing a popup window. I'm making an online portfolio, that has one base page with text and thumbnails. When a user clicks on a thumb, a new window opens containing a larger...
1
by: N. Graves | last post by:
Hi, I want to have a Search Dialog box that has several text box and fields to build a search and display the results in a form. I can do everything that I need to if I us a report but I would...
3
by: Greg | last post by:
On my report I want to have an opening balance signifying all transactions up to the month selected and detailed transactions for the month selected and then a closing blance. I'm perpelexed...
16
by: iwdu15 | last post by:
how can i open a file i saved and place the info into different text boxes?
7
by: Sam | last post by:
Hello All, We want our Call Service Representatives to be able to go back and view all the records in a table on a form. When closing and re-opening the form the form starts out as record 1 of 1...
1
by: Salad | last post by:
I have a form that opens another (intermediary) form. The user selects an option on the intermediary form and it opens another form and the intermediary form is closed. Ex: From MainForm...
3
by: Anthony P. | last post by:
Hello Everyone, I'm pretty new to VB.NET and I've run into a snag that I'm not really sure how to get around. I'm writing an application that shows a splashscreen, then a license agreement. When...
2
by: =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= | last post by:
I am (still) relatively new to Windows applications, most of my experience has been Web based, and I am confused about what exactly happens when the Main() method is called and how to manipulate...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...

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.