Solved

Open different form windows application

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed 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.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

707 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