Solved

Open different form windows application

Posted on 2006-11-25
4
171 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

910 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now