Solved

On Button Click Load Windows Form

Posted on 2008-09-29
2
1,668 Views
Last Modified: 2013-12-17
Its been a while sense I've used Visual Studio so bare with me.  What is the line of code that will load a new form when I click a button and run a check.  I would expect it to be Load.Form1.cs or something along those lines.  Thank you!
0
Comment
Question by:ReganJ03
2 Comments
 
LVL 14

Expert Comment

by:jaiganeshsrinivasan
ID: 22596267

yourFormName frmObject = new yourFormName();
frmObject.ShowDialog(); // or frmObject.Show();
0
 
LVL 15

Accepted Solution

by:
angus_young_acdc earned 50 total points
ID: 22596573
Here is what it would look like in your button.

The last two (this.hide and this.close) are optional and don't need to be done unless you want to, and you should pick one or the other (not use both as in the example below).  Also if you use Close on your main form it will stop your application completely, so all other forms will close.
        private void button1_Click(object sender, EventArgs e)

        {

            Form2 openForm = new Form2();

            openForm.Show();              // Opens the other form

           

            this.Hide();                // Hide the current form 

            this.Close();               // Closes the current form

        }

Open in new window

0

Featured Post

Free Trending Threat Insights Every Day

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 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

18 Experts available now in Live!

Get 1:1 Help Now