Solved

Open different form windows application

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 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