Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

On Button Click Load Windows Form

Posted on 2008-09-29
2
Medium Priority
?
1,681 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:Jai S
ID: 22596267

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

Accepted Solution

by:
angus_young_acdc earned 150 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 Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

916 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