Solved

Open different form windows application

Posted on 2006-11-25
4
170 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks allot
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 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

9 Experts available now in Live!

Get 1:1 Help Now