Solved

Open different form windows application

Posted on 2006-11-25
4
175 Views
Last Modified: 2010-04-16
Hi,

My application is in C# and using windows application

How to open new form when button is clicked on the differnt form and close the first form

Kind Regards
0
Comment
Question by:dinesh_bali
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 29

Expert Comment

by:Nightman
ID: 18011003
My understanding is that have a Main form A.
A opens form B
on FormB you have a button that you click. On click you want to open form C and close Form B.

If so, this should do it (place on form B):

private void Button_Click(object sender, System.EventArgs e)
{
  FormC frmC=new FormC();
  frmC.Show();
  this.Hide();
  this.Dispose();
}
0
 

Author Comment

by:dinesh_bali
ID: 18011340
Hi, Thanks for the solution.

But when I write this.Dispose();

then my frmC is not visible to me.

It seems both the form get dispose and application exits

even i tried the code like this also

     this.Hide();
     this.Dispose();
     Form2 frmC = new Form2();
     frmC.Show();

Can you help me that how can I dispose my form 1 only
0
 
LVL 29

Accepted Solution

by:
Nightman earned 250 total points
ID: 18011351
If form1 is the main application for you can't dispose it - this is because it is the entry point into your application. Is this the form that you are trying to dispose()?

Alternatively, simply hide the main form - form1.Hide().

I included the dispose method assuming this was a child of a child, not a child of the main form. This is because I wanted to make it clear that Hide() does not destroy or dispose of the resource.
0
 

Author Comment

by:dinesh_bali
ID: 18011353
Thanks allot
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question