Solved

On Button Click Load Windows Form

Posted on 2008-09-29
2
1,676 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
[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 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 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

627 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